Problem/Motivation
When displaying a button for a modal entity browser with auto open enabled, any future AJAX-Interaction on the page will cause the browser to pop up (again). I've encountered this problem mostly with Inline Entity Form Complex widgets, but assume it also happens in other setups.
This bug makes IEF Complex widgets unusable within Panels IPE, or when using multiple auto open widgets in the same form, or multi value fields with "Add more" - basically when using any AJAX interactions on the form.
While the potential conflicts with multiple fields using auto open are mentioned when configuring the entity browser, it cannot always be avoided and should definitely not occur on every single AJAX interaction.
This is a side effect of the commit in
#2778305-19: Open entity browser with one click from Entity Browser IEF widget →
, but I figured this should be its own issue as the code is already committed and discussion in that issue focusses on different aspects.
Replication steps:
Create an Entity Browser with the Modal display and auto open enabled
Use the Entity Browser on a multiple-cardinality Entity Reference or File/Image field
Open the form that contains the field, see the modal auto-open as expected, select some Entities
Once selection is complete, the browser opens again
--
samuel.mortenson →
I've also noticed that only the first function in instance.js_callbacks
gets bound to the button, because .entity-browser-processed
is added immediately.
Proposed resolution
Every instance should only be initialized once, that way all callbacks get added only once and the auto-open is only triggered when the button is first shown.
Would it be acceptable to add a jQuery.once call to the click() call introduced by this issue? [...] That way it would still auto-open on load, but after a selection is made or the modal closes, it wouldn't immediately open up again.
This most likely does not fix issues with entity browser in IEF simple widgets, but when using multiple of those in a single form, conflicts cannot sanely be avoided.