Skip to content

[material_ui] Announce PopupMenuButton with a child as a button - #12585

Merged
auto-submit[bot] merged 4 commits into
flutter:mainfrom
kaluli123123:port-191700-popupmenubutton-semantics
Sep 19, 2026
Merged

auto-submit[bot] merged 4 commits into
flutter:mainfrom
kaluli123123:port-191700-popupmenubutton-semantics

Conversation

@kaluli123123

@kaluli123123 kaluli123123 commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

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

  • flutter test test/popup_menu_test.dart
  • flutter test
  • flutter analyze
  • dart format --output=none --set-exit-if-changed packages/material_ui/lib/src/popup_menu.dart packages/material_ui/test/popup_menu_test.dart

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.

Footnotes

  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. ↩ ↩2

@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 PopupMenuButton to ensure button semantics, including enabled and expanded states, are correctly applied when the button is built with a custom child rather than the default icon. It also adds corresponding regression tests and a changelog entry. The review feedback suggests refactoring the mutable result variable to an immutable final widget using a conditional expression to align with idiomatic Dart practices.

Comment thread packages/material_ui/lib/src/popup_menu.dart Outdated
@Piinks

Piinks commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Hi @kaluli123123 thanks for porting over. Because of the volume of PRs we receive, we require that contributors use our checklist to guide them through critical steps in creating a Flutter PR. This PR's description is missing that checklist, so it is being marked as a Draft.

Please edit the PR description to add the checklist, then ensure that you have completed all of the steps. Once you've done that, please mark the PR as ready for review.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Also note, PRs in this repo need to be prepended with the package name they are changing, as in .. "[material_ui] "

@Piinks
Piinks marked this pull request as draft August 25, 2026 21:27
@dkwingsmt dkwingsmt changed the title Announce PopupMenuButton with a child as a button [material_ui] Announce PopupMenuButton with a child as a button Aug 25, 2026
@kaluli123123
kaluli123123 marked this pull request as ready for review September 8, 2026 03:24

@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 PopupMenuButton to ensure that button semantics, including enabled and expanded states, are correctly announced when the button is built with a custom child or a padded tap target size. It also adds corresponding regression tests and a changelog entry. There are no review comments, and I have no feedback to provide.

@QuncCccccc QuncCccccc added the CICD Run CI/CD label Sep 10, 2026

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

LGTM! Thanks for your contribution!

@QuncCccccc
QuncCccccc requested a review from chunhtai September 10, 2026 22:31
@QuncCccccc

Copy link
Copy Markdown
Contributor

Adding @chunhtai for a second review since this is related to a11y:)

@kaluli123123

Copy link
Copy Markdown
Contributor Author

Status check, since Dashboard Checks has been sitting at action_required on 2e48942 for a few days.

Re-verified the branch head locally against Flutter 3.44.7 stable:

$ flutter test test/popup_menu_test.dart
00:05 +103: All tests passed!

That includes the semantics tests this PR adds, plus the seven PopupMenu semantics for mismatched platforms variants.

I cannot read which presubmit task is unhappy — the dashboard link resolves to the SPA, and the public dashboard API only exposes postsubmit (/api/public/build-status reports packages green with no failing tasks). So I have no way to tell from outside whether this is a real task failure or a stale/expired run.

The branch is 108 commits behind main. I rebased it locally onto ac146c5 and it applied cleanly with no conflicts, so I can push that to re-trigger presubmit — but I have not, because the PR is already approved and Tree Hygiene asks contributors not to force push unless asked. Say the word and I will push the rebase; otherwise a re-run from the dashboard should settle it.

@chunhtai this is still waiting on your a11y look whenever you have a moment.

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

LGTM

@chunhtai chunhtai added autosubmit Merge PR when tree becomes green via auto submit App and removed autosubmit Merge PR when tree becomes green via auto submit App labels Sep 14, 2026
@chunhtai

Copy link
Copy Markdown
Contributor

vam and others added 3 commits September 14, 2026 15:09
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
@QuncCccccc
QuncCccccc force-pushed the port-191700-popupmenubutton-semantics branch from 2e48942 to fc1c99c Compare September 14, 2026 22:09
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 14, 2026
@QuncCccccc QuncCccccc added the CICD Run CI/CD label Sep 14, 2026
@QuncCccccc

Copy link
Copy Markdown
Contributor

The failures seems not relevant to this PR. Just re-triggered tests.

@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 18, 2026
@elliette elliette added the CICD Run CI/CD label Sep 18, 2026
@QuncCccccc QuncCccccc added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 19, 2026
@auto-submit
auto-submit Bot merged commit bbca61d into flutter:main Sep 19, 2026
14 checks passed
pull Bot pushed a commit to edisplay/flutter that referenced this pull request Sep 24, 2026
…er#193289)

Roll Packages from c2b58e1a97fb to 431ea69a42e2 (56 revisions)

flutter/packages@c2b58e1...431ea69

2026-09-24 [email protected] [cross_file]
Updates cross_file to a package separated federated plugin
(flutter/packages#11010)
2026-09-23 [email protected] [material_ui]
Remove static access of `copyWith` from `dart fix` golden tests for
`ThemeData/TextTheme` (flutter/packages#12994)
2026-09-23 [email protected] [camera_avfoundation] Replace
deprecated high-resolution capture APIs (flutter/packages#12372)
2026-09-23 [email protected] [pigeon] update nullish checks to use
new isNullish method (flutter/packages#12985)
2026-09-23 [email protected] [ci] Assign batch release PR approver
as reviewer on sync-back PR (flutter/packages#12976)
2026-09-23 [email protected] [image_picker] Fix scaling 10-bit images
(flutter/packages#12557)
2026-09-23 [email protected] [material_ui] Improve
Autocomplete, DrawerHeader, and Tooltip accessibility
(flutter/packages#12918)
2026-09-23 [email protected] [google_fonts] Decouple GoogleFontsLite
for full tree-shaking and add full feature parity
(flutter/packages#12830)
2026-09-23 [email protected] [file_selector]
Ignore flakey `file_selector_android` tests (flutter/packages#12992)
2026-09-23 [email protected] [CI] Remove
bringup from `Mac_arm64 build_all_packages` targets
(flutter/packages#12978)
2026-09-22 [email protected] [material_ui]
Unskip 5 passing web tests in bottom_app_bar_test and text_field_test
(flutter/packages#12983)
2026-09-22 [email protected]
[cupertino_ui] Unskip 5 passing web tests in
adaptive_text_selection_toolbar_test and text_field_test
(flutter/packages#12984)
2026-09-22 [email protected] [go_router] Fix ShellRoute chrome dropped
from semantics tree by ModalBarrier (flutter/packages#12353)
2026-09-22 [email protected] [material_ui]
Add contrastLevel for M3 ColorScheme (flutter/packages#12743)
2026-09-22 [email protected] [go_router] Preserve nested pushes
during config updates (flutter/packages#12611)
2026-09-22 [email protected] [material_ui]
Migrate M3 Chip template to use new gen_defaults
(flutter/packages#12847)
2026-09-22 [email protected] [material_ui] Fix
LocalHistoryEntry leak when double tapping Drawer scrim
(flutter/packages#12552)
2026-09-22 [email protected] Update suggested reviewers
(flutter/packages#12974)
2026-09-22 [email protected] Sync release-material_ui-1.4.0 to
main (flutter/packages#12966)
2026-09-22 [email protected] Sync release-cupertino_ui-1.1.1 to
main (flutter/packages#12965)
2026-09-21 [email protected] [ci] Update repo
for 3.47 stable release (flutter/packages#12959)
2026-09-21 [email protected] Manual roll Flutter from
27fec0e to 4fcd90b (1 revision) (flutter/packages#12904)
2026-09-21 [email protected] Revert "[go_router_builder] Migrate to
material_ui" (flutter/packages#12962)
2026-09-21 [email protected]
[material_ui] Update `material_ui` tests to prevent them from failing
when framework `TextStyle` changes (flutter/packages#12728)
2026-09-21 [email protected] [go_router_builder] Migrate to
material_ui (flutter/packages#12913)
2026-09-21 [email protected] [material_ui,
cupertino_ui] Bump Flutter version from to 3.47 (flutter/packages#12944)
2026-09-21 [email protected] [cupertino_ui] Work around dart2wasm
optional parameter inference bug in example checkbox tests
(flutter/packages#12961)
2026-09-21 [email protected] [cupertino_ui] Work around dart2wasm
optional parameter inference bug in checkbox_test.dart
(flutter/packages#12956)
2026-09-21 [email protected] [google_sign_in] PR 3/4 Migrate
ViewProvider and GID SDK wrappers from Objective-C to Swift
(flutter/packages#12657)
2026-09-21 [email protected] [google_sign_in] PR 2/4 Migrate
the plugin class from Objective-C to Swift. (flutter/packages#12655)
2026-09-20 [email protected]
[cross_file_darwin] iOS/macOS implementation of `cross_file`
(flutter/packages#12910)
2026-09-20 [email protected]
[cross_file_web] Web implementation of `cross_file`
(flutter/packages#12908)
2026-09-20 [email protected] [material_ui]
Migrate M3 `InputChip` template to use new gen_defaults
(flutter/packages#12850)
2026-09-20 [email protected] [material_ui]
Migrate M3 Checkbox defaults to new gen_defaults
(flutter/packages#12816)
2026-09-20 [email protected] [material_ui]
Migrate M3 `FilterChip` template to use new gen_defaults
(flutter/packages#12849)
2026-09-19 [email protected] [material_ui] Announce PopupMenuButton with a
child as a button (flutter/packages#12585)
2026-09-19 [email protected] Roll Flutter (stable) from
9584c67 to 6a19cca (7 revisions) (flutter/packages#12950)
2026-09-18 [email protected] [material_ui]
Reduce the `material_ui` non-wasm web test suite
(flutter/packages#12763)
2026-09-18 [email protected] Replace
`Mac_x64` builders with `Mac_arm64` ones (flutter/packages#12941)
2026-09-18 [email protected]
[in_app_purchase_storekit] Use `_$SKPaymentDiscountWrapperToJson`
(flutter/packages#12721)
2026-09-18 [email protected] [In_app _purchase] README
excerpt examples and changelog (flutter/packages#12739)
2026-09-18 [email protected] [material_ui] Add alternative
input method for `RangeSlider` in `NavigationMode.directional`
(flutter/packages#12630)
2026-09-18 [email protected]
[cross_file_android] Android implementation of `cross_file`
(flutter/packages#12909)
2026-09-18 [email protected]
[camera_platform_interface] Adds videoOutputPath support to
startVideoRecording (flutter/packages#12667)
2026-09-17 [email protected] [cupertino_ui] Migrate a
snippet in `CupertinoCheckbox`'s API doc to `{@example}` and add unit
tests (flutter/packages#12180)
2026-09-17 [email protected] [material_ui]
Default gen_defaults color helper prefix (flutter/packages#12848)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD p: material_ui triage-design Should be looked at in design triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[a11y] TalkBack announces PopupMenuButton incorrectly

5 participants