Allow TitleBar to not respond to onDoubleTap to fix visible delay on clicks#1340
Allow TitleBar to not respond to onDoubleTap to fix visible delay on clicks#1340artdedeco wants to merge 2 commits into
Conversation
…e caller doesn't provide a callback. Listening for `onDoubleTap` causes a 300ms delay on single taps (see flutter/flutter#110300)
There was a problem hiding this comment.
Code Review
This pull request refactors the TitleBar component to pass the onDoubleTap callback directly instead of wrapping it in an anonymous function. This prevents the gesture detector from listening to double taps when no callback is provided, avoiding a 300ms delay on single taps. There are no review comments, and I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
* Initial plan * fix: TitleBar height no longer shrinks when window is resized to smaller width (bdlukaa#1340) Co-authored-by: bdlukaa <45696119+bdlukaa@users.noreply.github.com> * fix: _TitleSubtitleOverflow intrinsic height includes hidden children Co-authored-by: bdlukaa <45696119+bdlukaa@users.noreply.github.com> * fix: Correctly position titlebar in compact overlay mode --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bdlukaa <45696119+bdlukaa@users.noreply.github.com> Co-authored-by: Bruno D'Luka <brunodlukaa@gmail.com>
|
I just noticed #1298 was responsible for adding this (support for double click callback) - I had thought it was a more fundamental design decision to support it from the start; Instead, it seems more like it was just an oversight in that implementation. I guess that makes this fix I'm proposing acceptable even long-term. |
The new
TitleBarcontrol, which replaces the oldNavigationAppBar, currently uses aGestureDetectorto respond to pan (drag) and double tap/click events. However,GestureDetectorhas a known, currently unresolved, issue where it adds a 300ms delay to single tap events when you listen toonDoubleTap, thus renderingTitleBarunusable in any desktop, mouse & keyboard environment.There are a few different avenues for fixing this on the library side, notably: 1) depend on a lower level gesture detection abstraction and choose our own algo for differentiating between single and double clicks - perhaps one better suited for mouse, given the target audience of the library; or 2) redesign the control so that gesture detection does not apply to the whole thing (which would have the added benefit of better aligning to Windows UX standards -- drag should not work when clicking on app icon or caption buttons, for example).
Given that both of those options would not only require non-trivial amount of work, but also a discussion phase, I'm proposing this change as a quick mitigation, so that at the very least it unblocks teams currently blocked by this, such as mine. The change is a one liner: from
onDoubleTap: () => onDoubleTap?.call()toonDoubleTap: onDoubleTap; the idea being that if the caller provides anullfunc toonDoubleTap, theonDoubleTapcallback fromGestureDetectoris never registered.I categorized the commit as
refactor(perf)following precedence on the changelog file, and given that the change does not alter the contract nor does it cause any externally visible change in behavior for the caller (beside the improved perf).Pre-launch Checklist
CHANGELOG.mdwith my changes