Repository navigation
fix(core): eliminate 300ms click delay and fix runtime controller prop changes - #10422
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f567030. Configure here.
…k delay The click recognizer's requireFailure dependency on dblclick causes mjolnir.js to defer click events by 300ms. Disabling doubleClickZoom by default removes this delay while keeping doubleClickDragZoom available for zoom-by-drag gestures. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Same principle — once #10416 lands, dblclickdrag should be in click's requireFailure list to prevent spurious clicks before a drag-zoom. That would reintroduce the 300ms delay, so disable by default too. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Prevents spurious click events from firing before a double-click-drag zoom gesture is recognized. Without this, a click would emit on the first tap before the recognizer determines the user intends to drag. Co-Authored-By: Claude Opus 4.6 <[email protected]>
f567030 to
e250fc9
Compare
Tests verify through the full EventManager → recognizer pipeline that: - Click fires immediately when doubleClickZoom and doubleClickDragZoom are both disabled (the new default) - Click is delayed ~300ms when doubleClickZoom is enabled - Click is delayed ~300ms when doubleClickDragZoom is enabled Also reorders RECOGNIZERS so dblclickdrag is registered before click, which is required for click's requireFailure reference to resolve. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…m is false The dblclick/dblclickdrag recognizers start with enable:false so they don't cause the 300ms click delay out of the box. Deck's picking system uses watch() (passive) for the dblclick event so it doesn't force-enable the recognizer. Only the controller's doubleClickZoom option enables it. Also adds integration tests that verify click latency at the Deck level using real pointer events dispatched to the canvas. Co-Authored-By: Claude Opus 4.6 <[email protected]>
| if (eventType === 'dblclick') { | ||
| // Use watch (passive) so the dblclick recognizer is only enabled by the | ||
| // controller's doubleClickZoom option — not by the picking system. | ||
| eventManager.watch(eventType, this._onEvent); |
There was a problem hiding this comment.
@Pessimistress while trying to unit test this, the LLM gathered some interesting context and proposed this change
The
watchchange atdeck.ts:1090is necessary to makedoubleClickZoom: falseactually eliminate the click delay.The problem: Deck registers handlers for both
clickanddblclickevents (for theonClickprop — it fires on both single and double clicks for picking). UsingeventManager.on('dblclick', ...)enables thedblclickrecognizer. The click recognizer hasdblclickin itsrequireFailurelist, so whendblclickis enabled,hasRequireFailures()returns true and the TapRecognizer adds a 300mssetTimeoutbefore emitting click.Even with
controller: {doubleClickZoom: false}, the controller callseventManager.off('dblclick', handler)— but the Deck-levelon('dblclick', ...)handler still exists, keeping the recognizer enabled and the delay in place.The fix:
watch()registers a passive handler that still receives dblclick events (soonClickstill fires on double-clicks whendoubleClickZoom: true), but passive handlers don't count towardisEmpty()— so they don't force-enable the recognizer. Only the controller'son/off(driven bydoubleClickZoom) controls whether the dblclick recognizer is active.Without this change, the
enable: falsedefault on the dblclick recognizer gets immediately overridden by Deck'son('dblclick', ...)call, and the 300ms click delay persists regardless of the controller setting.
I'm still investigating and learning about this area of deck..
The dblclick tests were broken because page.mouse.dblclick() doesn't properly target the canvas inside vitest's browser iframe. Fixed by dispatching PointerEvents directly on the canvas element, matching how mjolnir's PointerEventInput listener works (pointerdown on element, pointerup on window). Each test uses a fresh Deck instance for isolation. Co-Authored-By: Claude Opus 4.6 <[email protected]>
| if (eventType === 'dblclick') { | ||
| // Use watch (passive) so the dblclick recognizer is only enabled by the | ||
| // controller's doubleClickZoom option — not by the picking system. | ||
| eventManager.watch(eventType, this._onEvent); |
There was a problem hiding this comment.
context: on enables the recognizer, watch just passively watches already enabled recognizers.
This change is needed because without it in double click user's use case, if we disable double click zoom then double click also gets disabled. But that's not the expectation - the expectation is each event toggle is independent.
Deck._getViews() was mutating the View instance's props.controller in-place, so ViewManager._diffViews short-circuited on identity (same object) and never triggered _rebuildViewports. Controller option changes via setProps had no effect at runtime. Fixed by cloning the view when applying the controller prop. Also adds a gesture-timing test app that measures event handling delays and demonstrates the ~300ms click latency tradeoff with doubleClickZoom. - Restore doubleClickZoom=true default (breaking change avoidance) - Add regression test for runtime controller prop propagation - Add test/apps/gesture-timing for interactive delay measurement Co-Authored-By: Claude Opus 4.6 <[email protected]>
* upgrade mjolnir.js * fix(core): register dblclickdrag recognizer to recognize with click/dblclick (#10418) Co-authored-by: Claude Opus 4.8 <[email protected]> * fix(core): eliminate 300ms click delay and fix runtime controller prop changes (#10422) * fix(core): disable doubleClickZoom by default to eliminate 300ms click delay The click recognizer's requireFailure dependency on dblclick causes mjolnir.js to defer click events by 300ms. Disabling doubleClickZoom by default removes this delay while keeping doubleClickDragZoom available for zoom-by-drag gestures. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(core): also disable doubleClickDragZoom by default Same principle — once #10416 lands, dblclickdrag should be in click's requireFailure list to prevent spurious clicks before a drag-zoom. That would reintroduce the 300ms delay, so disable by default too. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(core): add dblclickdrag to click's requireFailure list Prevents spurious click events from firing before a double-click-drag zoom gesture is recognized. Without this, a click would emit on the first tap before the recognizer determines the user intends to drag. Co-Authored-By: Claude Opus 4.6 <[email protected]> * test(core): add click delay unit tests for controller gesture config Tests verify through the full EventManager → recognizer pipeline that: - Click fires immediately when doubleClickZoom and doubleClickDragZoom are both disabled (the new default) - Click is delayed ~300ms when doubleClickZoom is enabled - Click is delayed ~300ms when doubleClickDragZoom is enabled Also reorders RECOGNIZERS so dblclickdrag is registered before click, which is required for click's requireFailure reference to resolve. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(core): ensure dblclick recognizer is disabled when doubleClickZoom is false The dblclick/dblclickdrag recognizers start with enable:false so they don't cause the 300ms click delay out of the box. Deck's picking system uses watch() (passive) for the dblclick event so it doesn't force-enable the recognizer. Only the controller's doubleClickZoom option enables it. Also adds integration tests that verify click latency at the Deck level using real pointer events dispatched to the canvas. Co-Authored-By: Claude Opus 4.6 <[email protected]> * test(core): fix dblclick integration tests using direct pointer dispatch The dblclick tests were broken because page.mouse.dblclick() doesn't properly target the canvas inside vitest's browser iframe. Fixed by dispatching PointerEvents directly on the canvas element, matching how mjolnir's PointerEventInput listener works (pointerdown on element, pointerup on window). Each test uses a fresh Deck instance for isolation. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(core): propagate runtime controller prop changes to ViewManager Deck._getViews() was mutating the View instance's props.controller in-place, so ViewManager._diffViews short-circuited on identity (same object) and never triggered _rebuildViewports. Controller option changes via setProps had no effect at runtime. Fixed by cloning the view when applying the controller prop. Also adds a gesture-timing test app that measures event handling delays and demonstrates the ~300ms click latency tradeoff with doubleClickZoom. - Restore doubleClickZoom=true default (breaking change avoidance) - Add regression test for runtime controller prop propagation - Add test/apps/gesture-timing for interactive delay measurement Co-Authored-By: Claude Opus 4.6 <[email protected]> --------- Co-authored-by: Claude Opus 4.6 <[email protected]> * docs(core): document onClick(tapCount=2) side-effect of doubleClickZoom Co-Authored-By: Claude Opus 4.6 <[email protected]> --------- Co-authored-by: Charles Richardson <[email protected]> Co-authored-by: Claude Opus 4.8 <[email protected]> Co-authored-by: Chris Gervang <[email protected]> Co-authored-by: Chris Gervang <[email protected]>
…kZoom is off (#10384) (#10973) * fix(core): remove the 300ms click delay when doubleClickZoom is off (#10384) Backport of the click-delay part of #10422 (merged into master via #10416) to 9.3-release, without the DoubleClickDrag recognizer. - The dblclick recognizer starts disabled, and Deck watches dblclick for picking, so only the controller's doubleClickZoom option enables it - Clone the view when the controller prop changes so runtime changes apply - Interaction tests; they read the protected eventManager field because Deck.getEventManager() isn't on 9.3 * fix(core): copy the views array before applying the controller prop Cloning the first view wrote into the caller's views array, which throws when the array is frozen. * test(core): keep the frozen views array typed as View[]
|
Released in deck.gl 9.3.12, as #10973 on 9.3. |

Summary
controllerprop viadeck.setProps()had no effect (e.g., togglingdoubleClickZoomat runtime)dblclickanddblclickdragrecognizers start disabled and are only activated by their respective controller optionswatch()(passive) for dblclick in Deck's picking registration so the picking system doesn't force-enable the recognizerdblclickdragto click'srequireFailurelist so enabling double-click-drag zoom also correctly delays clicktest/apps/gesture-timinginteractive test app for measuring event handling delaysdoubleClickZoomis enabledBackground
When
doubleClickZoomis enabled (the default), theclickrecognizer hasrequireFailure: ['dblclick', 'dblclickdrag']. This causes mjolnir.js's TapRecognizer to defer click emission by ~300ms while waiting to see if a double-click follows. SettingdoubleClickZoom: falsedisables the recognizer, causinghasRequireFailures()to skip it and allowing clicks to fire immediately.Runtime controller prop bug (new fix)
Deck._getViews()was mutating the View instance'sprops.controllerin-place. WhenViewManager._diffViewscompared old and new views, they were the same object (this === view→ true inequals()), so it never triggered_rebuildViewportsandcontroller.setProps()was never called. Fixed by cloning the view instead of mutating it.Interaction with PR #9629 (onClick for double-click)
PR #9629 added
dblclick: 'onClick'toEVENT_HANDLERSso that double-clicking fires the layeronClickcallback withevent.tapCount: 2. This only works when the dblclick recognizer is active (i.e.,doubleClickZoom: true). DisablingdoubleClickZoomgives instant clicks but losesonClick(tapCount=2).See discussion in #10388 and the revert in #10420. Relates to #10384.
Changes
modules/core/src/lib/deck.ts_getViews()instead of mutating; usewatch()for dblclick pickingmodules/core/src/lib/constants.tsenable: falseto dblclick/dblclickdrag; add dblclickdrag to click's requireFailure; document orderingmodules/core/src/controllers/controller.tsdoubleClickDragZoom = false(new feature, hasn't shipped)docs/api-reference/core/controller.mdtest/interaction/map-controller.spec.tstest/apps/gesture-timing/Test plan
How to test the gesture-timing app
Click the map and observe the event log. Toggle
doubleClickZoomcheckbox or use preset buttons to see click latency change in real-time. Seetest/apps/gesture-timing/README.mdfor details on reading the log.Generated with Claude Code