Not a bug Unexpected (but understandable) js-disabler behavior

Justis R

Affected version
2.2.7 patch 1
When a js-disabler is used in a popup and that popup is closed, then another popup is opened which uses the same template, the js-disabler will become confused and stop working, because there's now multiple triggers and targets with the same ids registered to the page:

View attachment

I've circumvented the issue by suffixing the trigger/target ids with the entity ID, so each popup is unique, but I thought I'd toss it in here just in case anyone else was unaware that this happens, didn't realize why it was happening, or of course if the XF devs wanted to do something about it. Since circumventing it is so easily done, and is only a concern for popups such as shown above, I'd understand if this was a "won't-fix".
I came across this myself the other day, and it's because the modals are cached after they're opened, so when you open another one the same IDs are already on the page in the hidden cached modal. You can add cache="false" to the link or button that triggers the modal, and it will delete the element when it's closed, so won't clash with a new one that's opened. It's an inherent issue with using IDs in an element that will get created multiple times, there's not really a lot that can be done within the disabler js itself as you shouldn't have multiple elements with the same ID (i.e. it's more the modal caching than disabler itself that's the cause here). Making sure the IDs are unique would resolve it, but stopping the modals being cached is easier.
Yeah essentially the usage of non-unique IDs is the main culprit here which, as noted, there are workarounds for so this isn't something we'd view as a bug.
Top Bottom