Migration guide for semantics menu roles#11881
Merged
Conversation
9 tasks
Collaborator
|
Visit the preview URL for this PR (updated for commit 546a922): https://flutter-docs-prod--pr11881-semantics-menu-roles-ydcftdn7.web.app |
sfshaza2
requested changes
Apr 9, 2025
|
|
||
| ## Summary | ||
|
|
||
| `MenuAnchor`, `MenuBar`, `MenuItemButton`, `SubmenuButton`, `CheckboxMenuButton` |
Contributor
There was a problem hiding this comment.
Suggested change
| `MenuAnchor`, `MenuBar`, `MenuItemButton`, `SubmenuButton`, `CheckboxMenuButton` | |
| To support accessibility and ensure that screen readers announce roles correctly on the web, `MenuAnchor`, `MenuBar`, `MenuItemButton`, `SubmenuButton`, `CheckboxMenuButton`, |
Oxford comma for the win!
|
|
||
| The `MenuAnchor` and `MenuBar` widgets are used to show menus or sub-menus. | ||
| The children of these widgets are composed of menu items, such as | ||
| `MenuItemButton`, `SubmenuButton`, `CheckboxMenuButton` and `RadioMenuButton`. |
Contributor
There was a problem hiding this comment.
Suggested change
| `MenuItemButton`, `SubmenuButton`, `CheckboxMenuButton` and `RadioMenuButton`. | |
| `MenuItemButton`, `SubmenuButton`, `CheckboxMenuButton`, and `RadioMenuButton`. |
Comment on lines
+11
to
+13
| and `RadioMenuButton` have been wired up to `ARIA` menu roles. The menu button | ||
| widgets should only be used as children of the menu-related widgets, such as | ||
| `MenuAnchor` and `MenuBar`. |
Contributor
There was a problem hiding this comment.
Suggested change
| and `RadioMenuButton` have been wired up to `ARIA` menu roles. The menu button | |
| widgets should only be used as children of the menu-related widgets, such as | |
| `MenuAnchor` and `MenuBar`. | |
| and `RadioMenuButton` have been wired up to `ARIA` menu roles. | |
| These menu button widgets should only be used as children of | |
| menu-related widgets, such as `MenuAnchor` and `MenuBar`. |
Comment on lines
+21
to
+23
| To ensure the screen readers announce roles correctly on the web, after these | ||
| widgets are wired up to the `ARIA` menu roles, widgets with menu item roles | ||
| should only be used as children of widgets with `menu` or `menuBar` roles. |
Contributor
There was a problem hiding this comment.
Suggested change
| To ensure the screen readers announce roles correctly on the web, after these | |
| widgets are wired up to the `ARIA` menu roles, widgets with menu item roles | |
| should only be used as children of widgets with `menu` or `menuBar` roles. | |
| After these widgets are wired up to the `ARIA` menu roles, | |
| widgets with menu item roles should only be used as children | |
| of widgets with `menu` or `menuBar` roles. |
Comment on lines
+28
to
+30
| An error messages similar to "A menu item must be a child of a menu or a menu | ||
| bar" might appear if the app or a test directly uses menu item buttons instead | ||
| of using them within widgets with a role of `SemanticsRole.menu` or |
Contributor
There was a problem hiding this comment.
Suggested change
| An error messages similar to "A menu item must be a child of a menu or a menu | |
| bar" might appear if the app or a test directly uses menu item buttons instead | |
| of using them within widgets with a role of `SemanticsRole.menu` or | |
| An error messages similar to "A menu item must be a child of a menu or a menu | |
| bar" might appear if the menu item buttons are used directly instead | |
| of using them within widgets with a role of `SemanticsRole.menu` or |
Comment on lines
+34
to
+35
| For example, before the migration, if an app used a menu button outside of a | ||
| menu context: |
Contributor
There was a problem hiding this comment.
Suggested change
| For example, before the migration, if an app used a menu button outside of a | |
| menu context: | |
| Before migration: | |
| The following example uses a menu button outside of a menu context: |
Comment on lines
+51
to
+53
| An exception will be thrown and the error message will appear. Therefore, to | ||
| fix the error, replace the menu button widgets with other standard buttons, such | ||
| as: |
Contributor
There was a problem hiding this comment.
Suggested change
| An exception will be thrown and the error message will appear. Therefore, to | |
| fix the error, replace the menu button widgets with other standard buttons, such | |
| as: | |
| After migration: | |
| The previous code now throws an exception and displays an error message. | |
| To fix the error, replace the menu button widgets with other standard buttons: |
| ); | ||
| ``` | ||
|
|
||
| In tests, if a test was constructed as follows to test some features of the |
Contributor
There was a problem hiding this comment.
Suggested change
| In tests, if a test was constructed as follows to test some features of the | |
| An example test, before migration: |
| ); | ||
| ``` | ||
|
|
||
| After the migration, the test should be updated to: |
Contributor
There was a problem hiding this comment.
Suggested change
| After the migration, the test should be updated to: | |
| The same test, after migration: |
Contributor
Author
|
@sfshaza2 Thanks so much for your suggestions! Just updated all of them! |
QuncCccccc
added a commit
that referenced
this pull request
May 5, 2025
This reverts commit 6d1c1b4.
sfshaza2
pushed a commit
that referenced
this pull request
May 6, 2025
Reverts #11881 because flutter/flutter#165596 is reverted.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is to add a breaking change page for flutter/flutter#165596.
Presubmit checklist