[StimulusBundle] Event listener priority between Stimulus controllers #2912
Replies: 3 comments
-
Did you check the network tab of your browser "debug tools" ? As this one is registered lazy, maybe here even if the order is the correct one, the time for the Stimulus lazy loader to fetch/load the controller file the other one has connected. Could you try without stimulusFetch: lazy to see ? |
Beta Was this translation helpful? Give feedback.
-
But i wonder, re-reading your issue, if the best way to achieve your goal would not be to use a custom form theme (or just disabling the one provided) ? See Usage without Symfony Forms and Usage with Symfony Forms |
Beta Was this translation helpful? Give feedback.
-
Hello @smnandre, After some tests without stimulusFetch: lazy it seems the bug don't appear again. I have the same issue on other elements with multiple Stimulus controllers. I close this issue for now but I leave my ticket open on Hotwire Discussion |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone,
I need advice about Stimulus controllers events and listeners.
I have sometimes priority issues with event listeners.
The password input using Symfony UX Toggle Password and my custom controller :
I need to append controller’s element to closest
div.input-group
. Here is my controller :Sometimes, Symfony UX Toggle Password controller launches first, dispatchs the
toggle-password:connect
and then my controller is executed.Because of this, my controller misses Symfony UX Toggle Password controller’s connect event and don’t update element position in the DOM.
Is there a way to add a “priority” between controller’s events on a single DOM element to make sure event listeners work as intended ?
Thank you for your support !
Beta Was this translation helpful? Give feedback.
All reactions