Skip to content

Preserve Tooltip semantics when disabled by TooltipVisibility#189171

Closed
devzahirul wants to merge 1 commit into
flutter:masterfrom
devzahirul:fix-tooltip-visibility-semantics
Closed

Preserve Tooltip semantics when disabled by TooltipVisibility#189171
devzahirul wants to merge 1 commit into
flutter:masterfrom
devzahirul:fix-tooltip-visibility-semantics

Conversation

@devzahirul

Copy link
Copy Markdown

TooltipVisibility(visible: false) is documented to "only visually" disable tooltips while it "continues to provide any semantic information that is provided". Since the RawTooltip refactor (#177678), TooltipState.build skips the RawTooltip wrapper entirely when the tooltip is disabled. Because the Semantics(tooltip:) annotation now lives inside RawTooltip, it is dropped along with it, so assistive technologies stop announcing the tooltip message — for example, an IconButton with tooltip: 'Add' under TooltipVisibility(visible: false) is announced as just "button". Before that refactor, the Semantics wrapper was applied unconditionally and only gesture handling was gated on visibility.

This change restores the documented behavior: when a TooltipVisibility ancestor disables the tooltip, the child is still wrapped in the same Semantics(tooltip:) annotation that RawTooltip applies when the tooltip is enabled, honoring excludeFromSemantics. It adds a regression test that fails without the fix, plus a test verifying that excludeFromSemantics: true still 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.

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
@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Jul 9, 2026
@google-cla

google-cla Bot commented Jul 9, 2026

Copy link
Copy Markdown

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.

@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 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.

@devzahirul

Copy link
Copy Markdown
Author

This change targets the Material library, which is frozen in flutter/flutter per #184093. Closing in favor of the port to material_ui in flutter/packages, following the porting instructions in #188444: flutter/packages#12153

@devzahirul devzahirul closed this Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setting TooltipVisibility(visible: false) prevents tooltips contributing semantics

1 participant