Repository navigation
Reland "fix(widgets): dismiss open RawTooltip on Escape key (WCAG 1.4.13)" - #193192
Merged
auto-submit[bot] merged 3 commits intoSep 23, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request registers early key event handlers on FocusManager and HardwareKeyboard when a RawTooltip is shown, ensuring the Escape key dismisses the tooltip without triggering other focused elements or ancestor DismissIntent handlers. The feedback suggests refactoring these handlers to be static and managing their registration globally to avoid redundant allocations. Additionally, it recommends replacing a late final variable in the test's teardown block with a nullable variable to prevent potential LateInitializationErrors during setup failures.
…void late final OverlayEntry in test
navaronbracke
previously approved these changes
Sep 23, 2026
navaronbracke
left a comment
Contributor
There was a problem hiding this comment.
LGTM with nit
Thanks for the extra test, too!
Contributor
Author
|
@navaronbracke - need another nod from you, please |
navaronbracke
approved these changes
Sep 23, 2026
This was referenced Sep 23, 2026
9 tasks done
This was referenced Sep 24, 2026
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.
Relands #192966 (reverted in #193183) with
OverlayEntrydisposal inraw_tooltip_test.dartandFocusManagerearly key-event interception inraw_tooltip.dart.What changed since #192966 (
f8c85519a060)OverlayEntryLeak Fix (raw_tooltip_test.dart):raw_tooltip_test.dart(Escape key dismisses hovered RawTooltip even when primaryFocus is on a sibling consuming Escape),#192966passed an inlineOverlayEntry(...)toOverlay(initialEntries: <OverlayEntry>[...])without callingentry.remove()andentry.dispose()inaddTearDown. BecauseOverlaydoes not disposeinitialEntrieson unmount, theOverlayEntry's internalValueNotifier<_OverlayEntryWidgetState?>was flagged asnotDisposedbyleak_trackerin CI (Linux framework_tests_widgets_leak_tracking).OverlayEntry? entryand registersaddTearDown(() { entry?.remove(); entry?.dispose(); }). Verified locally withflutter test --dart-define=LEAK_TRACKING=true test/widgets/raw_tooltip_test.dart.EscapePropagation Before Focus-Tree Shortcuts (raw_tooltip.dart):#192966,RawTooltipStateregisteredHardwareKeyboard.instance.addHandler(_handleKeyEvent)alone. BecauseKeyEventManagerrunsHardwareKeyboardhandlers beforeFocusManager.handleKeyMessagewithout stopping the focus-tree walk when returningtrue, emptyingRawTooltip._openedTooltipsinHardwareKeyboardcausedEscapeto still reach focused siblings (siblingReceivedEscape) orWidgetsApp'sShortcuts(DismissIntenton enclosingModalRoutes such asDatePickerDialog).FocusManager.instance.addEarlyKeyEventHandler(_handleEarlyKeyEvent)plusHardwareKeyboard.instance.addHandler(_handleHardwareKeyEvent)fallback whenprimaryFocus == null) whenRawTooltip._openedTooltipstransitions from empty to non-empty, and removes them when the last open tooltip closes or disposes. ReturningKeyEventResult.handledfrom_handleEarlyKeyEventstopsFocusManagerbefore walking the focus tree, and a second test (Escape key dismisses open RawTooltip inside WidgetsApp without invoking ancestor DismissIntent) verifies both cases.Original description
Fixes http://b/463905826
WCAG 1.4.13 (Content on Hover or Focus) requires a mechanism to dismiss additional content triggered by pointer hover or keyboard focus (
Escapekey) without moving pointer hover or keyboard focus, and without unintended side effects such as dismissing an enclosing modal dialog (DatePickerDialog) when a tooltip is open.Pre-launch Checklist
///).