Unverified Commit b2c73754 authored by chunhtai's avatar chunhtai Committed by GitHub

makes PopupMenuitem merge the semantics of its child (#62062)

parent fe88a88a
......@@ -342,7 +342,8 @@ class PopupMenuItemState<T, W extends PopupMenuItem<T>> extends State<W> {
},
);
return Semantics(
return MergeSemantics(
child: Semantics(
enabled: widget.enabled,
button: true,
child: InkWell(
......@@ -351,6 +352,7 @@ class PopupMenuItemState<T, W extends PopupMenuItem<T>> extends State<W> {
mouseCursor: effectiveMouseCursor,
child: item,
),
)
);
}
}
......
......@@ -836,6 +836,90 @@ void main() {
semantics.dispose();
});
testWidgets('PopupMenuItem merges the semantics of its descendants', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(
MaterialApp(
home: Material(
child: PopupMenuButton<int>(
itemBuilder: (BuildContext context) {
return <PopupMenuItem<int>>[
PopupMenuItem<int>(
value: 1,
child: Row(
children: <Widget>[
Semantics(
child: const Text('test1'),
),
Semantics(
child: const Text('test2'),
),
],
),
),
];
},
child: const SizedBox(
height: 100.0,
width: 100.0,
child: Text('XXX'),
),
),
),
),
);
await tester.tap(find.text('XXX'));
await tester.pumpAndSettle();
expect(semantics, hasSemantics(
TestSemantics.root(
children: <TestSemantics>[
TestSemantics(
textDirection: TextDirection.ltr,
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[
SemanticsFlag.scopesRoute,
SemanticsFlag.namesRoute,
],
label: 'Popup menu',
textDirection: TextDirection.ltr,
children: <TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[
SemanticsFlag.hasImplicitScrolling,
],
children: <TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[
SemanticsFlag.isButton,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isFocusable,
],
actions: <SemanticsAction>[SemanticsAction.tap],
label: 'test1\ntest2',
textDirection: TextDirection.ltr,
),
],
),
],
),
],
),
TestSemantics(),
],
),
],
),
ignoreId: true, ignoreTransform: true, ignoreRect: true,
));
semantics.dispose();
});
testWidgets('disabled PopupMenuItem has correct semantics', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/45044.
final SemanticsTester semantics = SemanticsTester(tester);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment