Skip to content

Commit 8fe543a

Browse files
committed
Drop RawAutocomplete listBox wrapper; test option+isButton precedence
- Remove the Semantics(role: listBox) wrapper from RawAutocomplete. It only owns the overlay container, not the items, so it would ship role=listbox with role=button children. Both roles will be assigned together in material_ui (flutter#194031). - Add isButton to one option node in the web engine test to lock in that the explicit role wins over the button flag (the shape material_ui emits). - Update GenericRole comment wording.
1 parent b49211b commit 8fe543a

3 files changed

Lines changed: 7 additions & 10 deletions

File tree

‎engine/src/flutter/lib/web_ui/lib/src/engine/semantics/semantics.dart‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,9 +1105,9 @@ final class GenericRole extends SemanticRole {
11051105
// has no other role for the screen reader to be aware of. Normally the
11061106
// element does not need a `role` attribute at all, except when nested
11071107
// inside a menu, menubar, or listbox (such as the outer ListView
1108-
// semantics node in DropdownButton or RawAutocomplete), where omitting
1109-
// `role="none"` causes the browser to expose the element as an extra
1110-
// generic child of the container.
1108+
// semantics node in DropdownButton or an Autocomplete options list),
1109+
// where omitting `role="none"` causes the browser to expose the element
1110+
// as an extra generic child of the container.
11111111
super.update();
11121112
semanticsObject.owner.addOneTimePostUpdateCallback(() {
11131113
if (!semanticsObject.hasLabel && !semanticsObject.isTappable && hasMenuOrListBoxAncestor) {

‎engine/src/flutter/lib/web_ui/test/engine/semantics/semantics_test.dart‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3447,7 +3447,9 @@ void _testSelectables() {
34473447
role: ui.SemanticsRole.option,
34483448
label: 'apple',
34493449
hasTap: true,
3450-
flags: const ui.SemanticsFlags(isSelected: ui.Tristate.isTrue),
3450+
// isButton mirrors material_ui's per-item Semantics(button: true,
3451+
// selected: ...); the explicit role must win over the button flag.
3452+
flags: const ui.SemanticsFlags(isButton: true, isSelected: ui.Tristate.isTrue),
34513453
rect: const ui.Rect.fromLTRB(0, 0, 100, 30),
34523454
),
34533455
tester.updateNode(

‎packages/flutter/lib/src/widgets/autocomplete.dart‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -664,12 +664,7 @@ class _RawAutocompleteState<T extends Object> extends State<RawAutocomplete<T>>
664664
// traversal. Without this, TAB from the field would
665665
// detour into focusable items in the options overlay
666666
// instead of advancing to the next form field.
667-
child: Semantics(
668-
role: SemanticsRole.listBox,
669-
container: true,
670-
explicitChildNodes: true,
671-
child: ExcludeFocus(child: child),
672-
),
667+
child: ExcludeFocus(child: child),
673668
),
674669
),
675670
),

0 commit comments

Comments
 (0)