You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d8bf60c
Browse filesBrowse the repository at this point in the historyBrowse files
Fix Semantics expanded state not updating in PopupMenuButton and DropdownButton (flutter#183475)
Fixesflutter#183432
## Description
`_isMenuExpanded` is updated without calling `setState()` in both
`PopupMenuButton` and `DropdownButton`, so the `Semantics(expanded:
_isMenuExpanded)` widget doesn't rebuild.
**`PopupMenuButton`**: The `expanded` state never updates at all since
there is no `setState()` call anywhere in `PopupMenuButtonState`.
**`DropdownButton`**: Currently masked by `_handleFocusChanged`, which
happens to call `setState()` whenever focus changes on open/close, but
should not rely on this side effect.
### Changes
- Wrapped `_isMenuExpanded` assignments with `setState()` in both
widgets.
- For `DropdownButton`, moved `_isMenuExpanded = false` from
`_removeDropdownRoute()` to the `.then()` callback with a `mounted`
guard. This avoids unnecessary `setState()` calls when
`_removeDropdownRoute()` is invoked during `dispose()` or orientation
changes in `build()`, where the menu state isn't actually changing from
user interaction.
## Tests
Added regression tests for both `PopupMenuButton` and `DropdownButton`
to verify the `expanded` semantics state updates correctly when the menu
opens and closes.
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
0 commit comments