Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Check that only one resize listener is added to Grid containers #3096
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
Narrowing it down further I discovered it was to do with
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.
That change would prevent the
Why not just put your field layout designer in a nested div within the modal body?
Yep I can see it will affect all other event listeners, which is why I think this isn’t the solution.
But I’m confused as to why this is happening, nesting the fld inside another div doesn’t help, which after more testing makes me think its some kind of race condition due to grids being inside each other with resize events attached.
jQuery will de-dupe multiple attempts to attach the same event to the same node, so it shouldn’t be that there are multiple listeners attached as that shouldn’t be possible, I think its more to do with the way the listener gets removed and added in some kind of cycle.