Skip to content

bug: [#192] Fixed broken map event unmounting #193

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

robinmolen
Copy link
Contributor

Closes #192

To correctly unmount a event handler the map.on() and map.off() have to use the exact same props, otherwise the map.off() cannot correctly identify which handler to unmount, resulting in multiple (read duplicate) event handlers for the same event. See https://leafletjs.com/reference.html#evented-off for more information

By using a custom function on the map.on() (which in turn might call the correct props[handler]), the props[handler] is actually never used as event handler. Meaning that the map.off(), in the current setup, will never work.

By making sure that the map.on() and map.off() use the same function, the unmounting works as expected and old event handlers are removed.

I couldn't find a reason why this "function checking its own type, and then maybe calling the correct props[handler]" behaviour was implemented. If someone can tell me why (and preferably a bug report that shows an actual bug), i can look into a solution that uses the old setup.

When unmounting a specific map event handler (`map.off(eventType, func)`), the exact same mounting function (`map.on(eventType, func)`) has to be used. Otherwise the map unmounting doesn't know how which function should be removed, and nothing happens (resulting in more and more duplicate handlers for the same event). See https://leafletjs.com/reference.html#evented-off

By using a custom function on the `map.on()` (which in turn *might* call the correct `props[handler]`), the `props[handler]` is actually never used as event handler. Meaning that the `map.off()`, in the current setup, will never work.

By making sure that the `map.on()` and `map.off()` use the same function, the unmounting works as expected and old event handlers are removed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The handleChange function is fired multiple times during edit or delete operations.
1 participant