Repository navigation
[VPAT] Add an opt-in to show tooltips on keyboard focus - #13654
flutter-zl wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the showOnFocus property to Tooltip and TooltipThemeData, enabling tooltips to appear when their child widget receives keyboard focus. It includes corresponding updates to theme copying, interpolation, diagnostics, and comprehensive unit tests. Feedback on the changes suggests an improvement to the focus-loss handling: instead of calling Tooltip.dismissAllToolTips(), which dismisses all active tooltips on the screen, the code should re-assign _tooltipKey to a new GlobalKey within a setState call to dismiss only the current tooltip.
Fixes flutter/flutter#196562 Depends on #13654. This branch includes its commit, so review only the last commit: "[VPAT] Keep a11y_assessments tooltips open while hovered". I will rebase once #13654 lands. ## Problem In the a11y_assessments test app, plain-message tooltips use the material_ui default `ignorePointer: true`, so moving the mouse from a control onto its tooltip starts the exit timer and the tooltip disappears under the pointer. This fails WCAG 1.4.13 Hoverable on the date picker month arrows, the NavigationBar destinations, the Back and drawer menu buttons, and the app bar actions. ## Fix The app's shared theme adds `ignorePointer: false` next to `showOnFocus: true` in its `TooltipThemeData`, using the existing opt-in, so a hovered tooltip stays open. This touches only the test app, so there is no package version or CHANGELOG change, and the material_ui default is unchanged. Two tests cover it: every app theme sets `ignorePointer` to false, and an app bar `IconButton` tooltip stays open after the mouse moves onto it. ## Demo Before: https://flutter-demo-98-after.web.app/#/check-box-list-tile After: https://flutter-demo-99-after.web.app/#/check-box-list-tile Hover the Back button, then move the mouse down onto its tooltip. Before: the tooltip disappears. After: it stays open. `#/date-picker` after clicking Show Date Picker, `#/navigation-bar`, `#/drawer`, `#/navigation-drawer` and `#/app-bar` with "2. App bar with actions" selected show the same difference.
|
autosubmit label was removed for flutter/packages/13654, because Pull request flutter/packages/13654 is not in a mergeable state. |
|
Closing, this landed on main as part of #13657 (d050b77), which was stacked on top of this branch and was squash-merged with this commit included. Thanks @hannah-hyj for the review. |
Fixes flutter/flutter#196554
Problem
Tooltipopens only on mouse hover, long press or tap, never on keyboard focus. Icon-only controls likeBackButton,DrawerButton, the date picker month arrows and app barIconButtonactions rely on their tooltip to say what they do, so a sighted keyboard user who tabs to them sees a focus highlight and no label. Screen readers already announce the tooltip text, so the gap is visual only.Fix
Adds an opt-in
showOnFocustoTooltipandTooltipThemeData, default false. When it is on, the tooltip shows when its child gains focus whileFocusManager.highlightModeis traditional, hides when focus leaves, and Escape dismisses it without moving focus. Focus is observed with a listen-onlyFocus, so there is no extra Tab stop and no semantics change. Touch focus does not trigger it, which keeps mobile and TV behavior unchanged.RawTooltiphas no public way to close a single tooltip, so when a tooltip shown for focus loses focus, this callsdismissAllToolTips(). That also closes another tooltip the mouse is hovering at the same time. The a11y_assessments test app turns it on in its themes.Demo
Before: https://flutter-demo-98-before.web.app/#/date-picker
After: https://flutter-demo-98-after.web.app/#/date-picker
Click Show Date Picker, then press Tab to reach the month arrows. Before: focus highlight only. After: "Previous month", then "Next month".
#/check-box-list-tile,#/navigation-drawer,#/drawerand#/app-barshow the same difference on the Back, menu and action buttons.