Fix addBlocks and add option to append#11
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug in the HtmxComponent::addBlocks() method where the entire array was being added as a single element instead of merging its contents. Additionally, it adds an optional $append parameter to control whether blocks should be appended to existing blocks or replace them entirely.
- Fixed incorrect array assignment that was adding the entire input array as a nested element
- Added optional
$appendparameter with default value offalsefor backward compatibility - Updated parameter name and documentation for clarity
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
Thanks, I will do a release once I get the tests up. |
|
This is breaking change! |
|
True default behavior should be to append the block. |
|
@skie Please check the commit, how can this be a breaking change if the original method did not work ? :-) public function addBlocks(array $block): static
$this->blocks[] = $block;
}
//result
$blocks = [
['block']
];
//should be
$blocks [
'block'
];I hope you see the issue ? Maybe you are confusing it with the addBlock (singular) counterpart. @zunnu agreed :-) |
|
again: the method was broken so your original statement about breaking change does not apply. Concerning true or false, that's a design choice. But true seems fine by me :-) |
|
Changing it back to true in #13 |
Didn't caught this one in my previous MR.
HtmxComponent::addBlocks() adds its argument array as a child property of the blocks array.
Also added an append option.