Adapters: stop reporting a finished drawing's clicks as map clicks - #352
Open
CarsonDavis wants to merge 1 commit into
Open
Adapters: stop reporting a finished drawing's clicks as map clicks#352CarsonDavis wants to merge 1 commit into
CarsonDavis wants to merge 1 commit into
Conversation
terra-draw commits a shape on `pointerup`, but the click of that same gesture reaches the engine only afterwards — Leaflet on the native `click` that follows, deck.gl a tap interval later, since its `click` recognizer waits to see whether a double-click is coming. Both land with the session already over, so the adapters' "am I drawing?" check no longer covers them and every consumer is handed a map click the user never made: one that arrives after `drawcomplete` and clears the selection or dismisses whatever a plugin just opened. A time-based guard closes that gap. `DrawPointerWatch` tracks the pointer a session ends on, and `DrawEndClickGuard` holds back the clicks that pointer can still produce — through both taps of a double-click finish, holding terra-draw's double-click-zoom re-enable back with them, and closing early the moment the user opens a gesture of their own. Leaflet's click subscribers now fan out from one adapter-owned map listener, so the session is checked once where clicks are reported, the shape DeckGLAdapter's pointer path already had.
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Stops both map engines from reporting a finished drawing's own clicks as ordinary map clicks, by timing the clicks a finishing gesture can still produce and holding them back until they have all arrived.
Closes #351
What this changes
The phantom click is gone. terra-draw commits a shape on
pointerup, but the click of that same gesture reaches the engine afterwards — Leaflet on the nativeclickthat trails it, deck.gl a tap interval later, since itsclickrecognizer waits to rule out a double-click. Both land with the session already over, so the adapters' "am I drawing?" check no longer covers them. The two things a user saw for it: finishing a drawing silently deselected their active feature, and anything a plugin opened in response todrawcompletewas dismissed a moment later by a click that never happened.A time-based guard, not a counted one.
DrawPointerWatchtracks the pointer a session ends on;DrawEndClickGuardcovers the clicks that pointer can still produce. The window is timed off hammer's 300ms tap interval — the one number every click deck delivers is measured against — and each pointerup inside it re-opens the window for a settle period, long enough for the latest click the gesture can yield. It closes early too: a pointerdown too late to be the second tap of a double-click is the user starting a gesture of their own, and the window closes there and then rather than eating their click. A session that ends with no pointer that recent — Enter pressed while reading the shape back, a plugin's own Finish button — opens no window at all.Leaflet's clicks now funnel through one listener. Click subscribers registered through
on()hang off an adapter-owned map listener instead of off Leaflet directly, so the drawing session is checked once, where clicks are reported, rather than at every subscription. That is the shape DeckGLAdapter's pointer-click path already had;_onPointerClick/_onPointerHoverare extracted there so both wiring modes share one copy.Map_.js's feature-deselect handler moves onto the engine click path so it inherits the guard.A double-click finish no longer zooms the map. terra-draw turns double-click zoom back on the instant the mode stops, which would let the finishing gesture's second tap zoom on top of everything else it does. The guard holds that re-enable back for as long as it is absorbing the same gesture's clicks, and gives back the state the map actually had — a deployment that configures double-click zoom off keeps it off.
#303 stacks on this: the popup service's click-away dismissal is what made the phantom click visible, and depends on this guard to not close a card the moment it opens.