Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TwigComponent] Merge data-action in ComponentAttributes #1288

Conversation

weaverryan
Copy link
Member

Q A
Bug fix? yes
New feature? no
Issues None that I know of
License MIT

If you pass data-action into a component & the root attributes has a data-action already thanks to attributes.defaults, they should be merged together. Same behavior as data-controller. I found this while adding a data-action to a component and suddenly losing my existing data-action from inside.

Cheers!

@norkunas
Copy link
Contributor

What if I want to override the data-action totally, will it be possible? :)

@weaverryan weaverryan force-pushed the twig-component-attributes-data-action-merging branch from 3890b24 to 0cafa36 Compare November 22, 2023 00:22
@weaverryan
Copy link
Member Author

weaverryan commented Nov 22, 2023

What if I want to override the data-action totally, will it be possible? :)

Nope :). It's a valid question. Right now, data-controller and class are already "merge". This is hardcoded in. I've talked with @kbond a bit about adding some sort of API to replace vs merge. That's something we need to add. In the mean time, this is the "closer to proper" behavior.

So, we can't have it both ways right now. Currently, it's not possible to merge a data-action from the inside with a data-action from the outside. However, at the very least, you could introduce some other "prop" flag and use that to turn on / off an internal data-action after this PR. Since data-controller merges, this is closer to the correct behavior.

@weaverryan weaverryan merged commit 7794893 into symfony:2.x Dec 1, 2023
34 checks passed
@weaverryan weaverryan deleted the twig-component-attributes-data-action-merging branch December 2, 2023 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants