Skip to content

Announce PopupMenuButton with a child as a button - #191700

Closed
kaluli123123 wants to merge 1 commit into
flutter:masterfrom
kaluli123123:fix-popupmenubutton-semantics-147043
Closed

kaluli123123 wants to merge 1 commit into
flutter:masterfrom
kaluli123123:fix-popupmenubutton-semantics-147043

Conversation

@kaluli123123

Copy link
Copy Markdown
Contributor

PopupMenuButton only exposed button semantics when it built its own
IconButton. When a child was supplied, the widget just wrapped the
child in a Tooltip and an InkWell, so the semantics node had a tap
action but no button flag and no enabled state. Assistive technologies
therefore did not announce it as a button, and disabled buttons looked
enabled. The expanded state was also dropped entirely when
ButtonStyle.tapTargetSize was MaterialTapTargetSize.padded, because
that branch returned early before the Semantics wrapper was added.

The child branch now always wraps the result in a single Semantics
widget that marks the popup menu button as a button, reports the enabled
state and keeps the expanded state, for both tap target sizes.

Fixes #147043

Pre-launch Checklist

PopupMenuButton only exposed button semantics when it built its own
IconButton. When a `child` was supplied, the widget just wrapped the
child in a Tooltip and an InkWell, so the semantics node had a tap
action but no button flag and no enabled state. Assistive technologies
therefore did not announce it as a button, and disabled buttons looked
enabled. The `expanded` state was also dropped entirely when
`ButtonStyle.tapTargetSize` was `MaterialTapTargetSize.padded`, because
that branch returned early before the `Semantics` wrapper was added.

The `child` branch now always wraps the result in a single `Semantics`
widget that marks the popup menu button as a button, reports the enabled
state and keeps the expanded state, for both tap target sizes.

Fixes flutter#147043
@github-actions

Copy link
Copy Markdown

This pull request contains changes to Material or Cupertino, which are currently frozen in this repository.

Changes should be made in material_ui and/or cupertino_ui in the flutter/packages repository.

Please refer to #188444 for instructions.

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages labels Aug 25, 2026
@kaluli123123

Copy link
Copy Markdown
Contributor Author

Material is frozen in flutter/flutter (see #188444), so this is ported to flutter/packages instead: flutter/packages#12585. Closing this in favor of that PR.

QuncCccccc pushed a commit to kaluli123123/packages that referenced this pull request Sep 14, 2026
PopupMenuButton only exposed button semantics when it built its own
IconButton. When a child was supplied, the widget just wrapped the
child in a Tooltip and an InkWell, so the semantics node had a tap
action but no button flag and no enabled state. Assistive technologies
therefore did not announce it as a button, and disabled buttons looked
enabled. The expanded state was also dropped entirely when
ButtonStyle.tapTargetSize was MaterialTapTargetSize.padded, because
that branch returned early before the Semantics wrapper was added.

The child branch now always wraps the result in a single Semantics
widget that marks the popup menu button as a button, reports the
enabled state and keeps the expanded state, for both tap target sizes.

Ported from flutter/flutter#191700, which is blocked by the Material
code freeze.

Fixes flutter/flutter#147043
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Sep 19, 2026
Ports flutter/flutter#191700, which is blocked by the Material/Cupertino code freeze in flutter/flutter (see flutter/flutter#188444).

## Original description

`PopupMenuButton` only exposed button semantics when it built its own `IconButton`. When a `child` was supplied, the widget just wrapped the child in a `Tooltip` and an `InkWell`, so the semantics node had a tap action but no button flag and no enabled state. Assistive technologies therefore did not announce it as a button, and disabled buttons looked enabled. The `expanded` state was also dropped entirely when `ButtonStyle.tapTargetSize` was `MaterialTapTargetSize.padded`, because that branch returned early before the `Semantics` wrapper was added.

The `child` branch now always wraps the result in a single `Semantics` widget that marks the popup menu button as a button, reports the enabled state, and keeps the expanded state for both tap target sizes.

Fixes flutter/flutter#147043

## Test plan

## Pre-Review Checklist

The change uses the repository's pending changelog workflow (`packages/material_ui/pending_changelogs/change_2026_08_25_port191700.yaml`). No public API documentation change is needed.

[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[a11y] TalkBack announces PopupMenuButton incorrectly

1 participant