Repository navigation
Fix MouseWheelZoom target cleanup - #17640
Conversation
Listen for map target changes so document-level Ctrl key handlers are removed when a target is cleared and rebound when it changes. Fixes openlayers#17497
|
Two things while reading this:
Note also that no checks have reported on this branch yet, so nothing has verified the test/typecheck claims above — if that's a first-time-contributor approval thing, a maintainer may need to kick CI off. |
|
Thanks — both points were valid. I restored the |
|
Before I review this, please clean up description and code so it becomes human readable. |
|
📦 Preview the website for this branch here: https://deploy-preview-17640--ol-site.netlify.app/. |
ahocevar
left a comment
There was a problem hiding this comment.
If the comments in #17497 hold true, the fix for the problem that this pull request claims to fix is not in the MouseWheelZoom control, but in the Map. When setTarget(null) is called on the map, the target of all controls should be set to null, and when setTarget(target) is called, the target of the controls should be set back to the map.
|
Thanks. To make sure I follow the intended lifecycle: should handleTargetChanged_() detach and reattach both controls and interactions on target changes? MouseWheelZoom is an interaction, so updating controls alone would not release its document listeners. I can move the fix entirely into Map and cover both setTarget(null) and a target switch there. |
|
Sorry, I meant interactions, not controls — and it's just a matter of calling But I took a closer look at the existing code, and it seems the MouseWheelZoom does not need its own keydown and keyup events, because the map registers them already. So a better fix would be for the MouseWheelZoom to reuse them. |
|
One thing worth checking before reusing the map's keyboard events here: the map registers
So if the own listeners are dropped without adding a keyup somewhere, the flag stays If reuse is the way to go, the map would probably need a |
beb2290 to
f30a7d8
Compare
ahocevar
left a comment
There was a problem hiding this comment.
I took the liberty to change things so MapBrowserEvent handles the ctrlKey separate from the existing keydown/keypress handlers. This simplifies things quite a bit.
f30a7d8 to
b5fd008
Compare
Fixes #17497.
MouseWheelZoom now reuses the map's keyboard event handling to track the physical Control key instead of registering its own document listeners. The map also forwards keyup events to interactions.
Validated with: