Preserve Tooltip semantics when disabled by TooltipVisibility#189171
Preserve Tooltip semantics when disabled by TooltipVisibility#189171devzahirul wants to merge 1 commit into
Conversation
TooltipVisibility(visible: false) is documented to only visually disable tooltips while continuing to provide semantic information. Since the RawTooltip refactor (flutter#177678), TooltipState.build skips the RawTooltip wrapper entirely when the tooltip is disabled. Because the Semantics(tooltip:) annotation now lives inside RawTooltip, it was dropped along with it, and assistive technologies no longer announce the tooltip message. Wrap the child in the same Semantics annotation RawTooltip applies, honoring excludeFromSemantics, when the tooltip is disabled. Fixes flutter#189062
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request updates the Tooltip widget to ensure that its message is still reported to assistive technology via semantics when a TooltipVisibility ancestor has disabled the tooltip overlay, unless excludeFromSemantics is set to true. It also adds corresponding regression tests to verify this behavior. There are no review comments to address.
|
This change targets the Material library, which is frozen in flutter/flutter per #184093. Closing in favor of the port to |
TooltipVisibility(visible: false)is documented to "only visually" disable tooltips while it "continues to provide any semantic information that is provided". Since theRawTooltiprefactor (#177678),TooltipState.buildskips theRawTooltipwrapper entirely when the tooltip is disabled. Because theSemantics(tooltip:)annotation now lives insideRawTooltip, it is dropped along with it, so assistive technologies stop announcing the tooltip message — for example, anIconButtonwithtooltip: 'Add'underTooltipVisibility(visible: false)is announced as just "button". Before that refactor, theSemanticswrapper was applied unconditionally and only gesture handling was gated on visibility.This change restores the documented behavior: when a
TooltipVisibilityancestor disables the tooltip, the child is still wrapped in the sameSemantics(tooltip:)annotation thatRawTooltipapplies when the tooltip is enabled, honoringexcludeFromSemantics. It adds a regression test that fails without the fix, plus a test verifying thatexcludeFromSemantics: truestill suppresses the semantics when the tooltip is disabled.Fixes #189062
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.