Skip to content

Controller declaration order matters ? #82

Open
@Wait4Code

Description

@Wait4Code

After upgrading to v3.2.2, i've noticed that declaration order of stimulus controllers in HTML matters.
In my project I'm using symfony/ux-autocomplete and I have a custom controller to override tom-select options rendering.
All my controllers are fetch in eager mode.

Here is an example :

<select id="new_link_sap_order_item" class="form-control" required
        {{ stimulus_controller({
            'symfony/ux-autocomplete/autocomplete':{
                url: path('colporteur_find_sap_order_lines')
            },
            'colporteur--sap-order-item-select':{},
        }) }}>
</select>

Not declaring colporteur--sap-order-item-select before symfony/ux-autocomplete/autocomplete in the HTML, leads to custom controller connecting but never intercepting the autocomplete:pre-connect event dispatched by ux-autocomplete controller.

Obviously, i've fix this by putting my custom controller in first position :

<select id="new_link_sap_order_item" class="form-control" required
        {{ stimulus_controller({
            'colporteur--sap-order-item-select':{},
            'symfony/ux-autocomplete/autocomplete':{
                url: path('colporteur_find_sap_order_lines')
            }
        }) }}>
</select>

But I do not really like things that depends on declaration order to work.
Is this a wanted behaviour ? Maybe I'm opening issue in the wrong repo and should open it on symfony/ux one ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions