Check that only one resize listener is added to Grid containers #3096
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a bit of a weird one and relates to this issue for the Spoon plugin.
I have narrowed it down to an infinite loop occurring if you open a
Craft.FieldLayoutDesigner
inside aGarnish.Modal
. You can see the loop behaviour here:https://joshangell.s3.amazonaws.com/share/screencast_2018-07-14_09-56-19.mp4
Narrowing it down further I discovered it was to do with
Craft.Grid
adding back on the resize event listener. It seems that in this case it adds more than one and they race against each other in some way.One way around it that I came up with was to only add the resize listener if there weren’t any other listeners already attached to that element, as demonstrated in the PR. However, that doesn’t take into account the fact that other event listeners may have already been added before we get to this point.
The only way around that sort of scenario is to add a library or set of methods that deal with checking what kind of listeners are attached to elements so we can test if there is already specifically a resize listener and thus not be affected by any others. But that seemed a bit beyond the scope of what I was hoping to achieve, so I thought I would reach out now to start the conversation.
Obviously in terms of the plugin I have other options, such as not opening it in a modal, but it would be nice to be able to do so.
Thanks!