-
Notifications
You must be signed in to change notification settings - Fork 433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix global keyboard and window listeners are not removed after the map is destroyed #1434
fix global keyboard and window listeners are not removed after the map is destroyed #1434
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, good catch!
I will approve this but are you able to add some tests?
And do you think we have with some other Mixins problems when there are multiple maps?
@Falke-Design Just added a simple test case but I'm not sure if it's enough.
It looks other mixins are not binding events on the global objects like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is enough for now. Please check out the comments
…d function Co-authored-by: Florian Bischof <[email protected]>
Co-authored-by: Florian Bischof <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution!
Hi,
I noticed the global listeners bound in the keyboard mixin were not unbound after the map was destroyed, which makes the listener always exist and makes the code throw errors even if the component is destroyed in those single-page applications.
So I think we should unbind the listeners somewhere after destroying the map. I currently put this logic into the
_initKeyListener
function of theKeyboard
mixin. Also, to keep the isolation of the mixin, I changed the singleton Keyboard mixin object to a function that returns a new object at each call to make it work for multiple map instances, or the entire listener will be removed as long as one map is destroyed, which causes the event listener for other maps to not work.To reproduce,
demo/index.html
in this project and callmap.remove()