Skip to content

Revert: fix(widgets): dismiss open RawTooltip on Escape key (WCAG 1.4.13) - #193183

Merged
jtmcdole merged 1 commit into
flutter:masterfrom
flutteractionsbot:revert-192966-1790110499
Sep 22, 2026
Merged

jtmcdole merged 1 commit into
flutter:masterfrom
flutteractionsbot:revert-192966-1790110499

Conversation

@flutteractionsbot

@flutteractionsbot flutteractionsbot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Reverts: fix(widgets): dismiss open RawTooltip on Escape key (WCAG 1.4.13)

Initiated by: @b-luk

Reason for reverting: Breaks Windows framework_tests_widgets_leak_tracking. https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8669930694849114497/+/u/run_test.dart_for_framework_tests_shard_and_subshard_widgets/stdout

01:23 +4311 ~114 -1: C:/b/s/w/ir/x/w/flutter/packages/flutter/test/widgets/raw_tooltip_test.dart: (tearDownAll) [E]
  Expected: leak free
    Actual: <Instance of 'Leaks'>
     Which: contains leaks:
            # The text is generated by leak_tracker.
            # For leak troubleshooting tips open:
            # https://github.com/flutter/flutter/blob/main/docs/contributing/testing/Leak-tracking.md
            notDisposed:
              total: 2
              objects:
                ValueNotifier<_OverlayEntryWidgetState?>:
                  test: Escape key dismisses hovered RawTooltip even when primaryFocus is on a sibling consuming Escape
                  identityHashCode: 520722467
                OverlayEntry:
                  test: Escape key dismisses hovered RawTooltip even when primaryFocus is on a sibling consuming Escape
                  identityHashCode: 418743465
            
            
  
  package:matcher                                              expect
  package:leak_tracker_testing/src/leak_testing.dart 69:24     LeakTesting.collectedLeaksReporter.<fn>
  package:leak_tracker_flutter_testing/src/testing.dart 74:37  maybeTearDownLeakTrackingForAll
  ===== asynchronous gap ===========================
  dart:async                                                   Zone.registerBinaryCallback
  package:flutter_test/src/test_compat.dart 302:3              _tearDownForTestFile

Original PR Author: @kevmoo

Reviewed By: @navaronbracke

The original PR description is provided below:

Description

Improves RawTooltip keyboard accessibility (WCAG 1.4.13 Dismissible, http://b/463905826):

  • RawTooltip Escape key dismissal: Registers a HardwareKeyboard handler in RawTooltipState that dismisses open tooltips on LogicalKeyboardKey.escape (KeyDownEvent) and consumes the key event when a tooltip is open, preventing Escape from prematurely closing parent modal dialogs (such as DatePickerDialog) while a tooltip is displayed.
  • (Note: The accompanying Material changes for Autocomplete, DrawerHeader, and TooltipThemeData.ignorePointer will be submitted separately to packages/material_ui in flutter/packages per #188444).

Fixes http://b/463905826

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the global HardwareKeyboard event handler and the _handleKeyEvent method from RawTooltipState, which were used to dismiss tooltips when the Escape key was pressed. Additionally, the corresponding test case verifying this Escape key dismissal behavior has been removed. There are no review comments, so I have no feedback to provide.

@b-luk
b-luk requested a review from kevmoo September 22, 2026 20:56
@b-luk b-luk added the emergency Jump the queue; land PR in front of all others; only use for emergencies label Sep 22, 2026
@flutter-dashboard

Copy link
Copy Markdown

Detected the emergency label.

If you add the autosubmit label, the bot will wait until all presubmits pass but ignore the tree status, allowing fixes for tree breakages while still validating that they don't break any existing presubmits.

The "Merge" button is also unlocked. To bypass presubmits as well as the tree status, press the GitHub "Add to Merge Queue".

@kevmoo kevmoo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. also investigating so we can avoid this in the future

@b-luk
b-luk enabled auto-merge September 22, 2026 21:04
@b-luk b-luk added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 22, 2026
@b-luk
b-luk disabled auto-merge September 22, 2026 21:11
@github-actions github-actions Bot added the framework flutter/packages/flutter repository. See also f: labels. label Sep 22, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 22, 2026
@auto-submit

auto-submit Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

auto label is removed for flutter/flutter/193183, Failed to enqueue flutter/flutter/193183 with HTTP 400: Pull request Required status check "Check Code Freeze" is queued..

@b-luk b-luk added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 22, 2026
@jtmcdole jtmcdole added emergency Jump the queue; land PR in front of all others; only use for emergencies and removed emergency Jump the queue; land PR in front of all others; only use for emergencies labels Sep 22, 2026
@jtmcdole
jtmcdole enabled auto-merge September 22, 2026 21:44
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 22, 2026
@auto-submit

auto-submit Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

auto label is removed for flutter/flutter/193183, Failed to enqueue flutter/flutter/193183 with HTTP 400: Pull request Required status check "Check Code Freeze" is queued..

@jtmcdole
jtmcdole added this pull request to the merge queue Sep 22, 2026
Merged via the queue into flutter:master with commit 09543a0 Sep 22, 2026
46 of 47 checks passed
@flutteractionsbot
flutteractionsbot deleted the revert-192966-1790110499 branch September 22, 2026 22:55
pull Bot pushed a commit to fucheng-guo-sun/flutter that referenced this pull request Sep 23, 2026
….13)" (flutter#193192)

Relands flutter#192966 (reverted in
flutter#193183) with `OverlayEntry`
disposal in `raw_tooltip_test.dart` and `FocusManager` early key-event
interception in `raw_tooltip.dart`.

### What changed since flutter#192966 (`f8c85519a060`)

1. **Test `OverlayEntry` Leak Fix (`raw_tooltip_test.dart`)**:
- In `raw_tooltip_test.dart` (`Escape key dismisses hovered RawTooltip
even when primaryFocus is on a sibling consuming Escape`), `flutter#192966`
passed an inline `OverlayEntry(...)` to `Overlay(initialEntries:
<OverlayEntry>[...])` without calling `entry.remove()` and
`entry.dispose()` in `addTearDown`. Because `Overlay` does not dispose
`initialEntries` on unmount, the `OverlayEntry`'s internal
`ValueNotifier<_OverlayEntryWidgetState?>` was flagged as `notDisposed`
by `leak_tracker` in CI (`Linux framework_tests_widgets_leak_tracking`).
- This reland captures `OverlayEntry? entry` and registers
`addTearDown(() { entry?.remove(); entry?.dispose(); })`. Verified
locally with `flutter test --dart-define=LEAK_TRACKING=true
test/widgets/raw_tooltip_test.dart`.
2. **Stop `Escape` Propagation Before Focus-Tree Shortcuts
(`raw_tooltip.dart`)**:
- In `flutter#192966`, `RawTooltipState` registered
`HardwareKeyboard.instance.addHandler(_handleKeyEvent)` alone. Because
`KeyEventManager` runs `HardwareKeyboard` handlers *before*
`FocusManager.handleKeyMessage` without stopping the focus-tree walk
when returning `true`, emptying `RawTooltip._openedTooltips` in
`HardwareKeyboard` caused `Escape` to still reach focused siblings
(`siblingReceivedEscape`) or `WidgetsApp`'s `Shortcuts` (`DismissIntent`
on enclosing `ModalRoute`s such as `DatePickerDialog`).
- This reland registers a single static pair
(`FocusManager.instance.addEarlyKeyEventHandler(_handleEarlyKeyEvent)`
plus `HardwareKeyboard.instance.addHandler(_handleHardwareKeyEvent)`
fallback when `primaryFocus == null`) when `RawTooltip._openedTooltips`
transitions from empty to non-empty, and removes them when the last open
tooltip closes or disposes. Returning `KeyEventResult.handled` from
`_handleEarlyKeyEvent` stops `FocusManager` before 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
(`Escape` key) 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

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] All existing and new tests are passing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD emergency Jump the queue; land PR in front of all others; only use for emergencies framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants