This reverts commit c6058df9ca8e871772c4a0444cff43690e33cb0d.
This commit is contained in:
parent
c6058df9ca
commit
067d3da827
@ -342,15 +342,11 @@ class PopupMenuItemState<T, W extends PopupMenuItem<T>> extends State<W> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
return Semantics(
|
return InkWell(
|
||||||
enabled: widget.enabled,
|
onTap: widget.enabled ? handleTap : null,
|
||||||
button: true,
|
canRequestFocus: widget.enabled,
|
||||||
child: InkWell(
|
mouseCursor: effectiveMouseCursor,
|
||||||
onTap: widget.enabled ? handleTap : null,
|
child: item,
|
||||||
canRequestFocus: widget.enabled,
|
|
||||||
mouseCursor: effectiveMouseCursor,
|
|
||||||
child: item,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -765,175 +765,31 @@ void main() {
|
|||||||
],
|
],
|
||||||
children: <TestSemantics>[
|
children: <TestSemantics>[
|
||||||
TestSemantics(
|
TestSemantics(
|
||||||
flags: <SemanticsFlag>[
|
flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
|
||||||
SemanticsFlag.isButton,
|
|
||||||
SemanticsFlag.hasEnabledState,
|
|
||||||
SemanticsFlag.isEnabled,
|
|
||||||
SemanticsFlag.isFocusable,
|
|
||||||
],
|
|
||||||
actions: <SemanticsAction>[SemanticsAction.tap],
|
actions: <SemanticsAction>[SemanticsAction.tap],
|
||||||
label: '1',
|
label: '1',
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
),
|
),
|
||||||
TestSemantics(
|
TestSemantics(
|
||||||
flags: <SemanticsFlag>[
|
flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
|
||||||
SemanticsFlag.isButton,
|
|
||||||
SemanticsFlag.hasEnabledState,
|
|
||||||
SemanticsFlag.isEnabled,
|
|
||||||
SemanticsFlag.isFocusable,
|
|
||||||
],
|
|
||||||
actions: <SemanticsAction>[SemanticsAction.tap],
|
actions: <SemanticsAction>[SemanticsAction.tap],
|
||||||
label: '2',
|
label: '2',
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
),
|
),
|
||||||
TestSemantics(
|
TestSemantics(
|
||||||
flags: <SemanticsFlag>[
|
flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
|
||||||
SemanticsFlag.isButton,
|
|
||||||
SemanticsFlag.hasEnabledState,
|
|
||||||
SemanticsFlag.isEnabled,
|
|
||||||
SemanticsFlag.isFocusable,
|
|
||||||
],
|
|
||||||
actions: <SemanticsAction>[SemanticsAction.tap],
|
actions: <SemanticsAction>[SemanticsAction.tap],
|
||||||
label: '3',
|
label: '3',
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
),
|
),
|
||||||
TestSemantics(
|
TestSemantics(
|
||||||
flags: <SemanticsFlag>[
|
flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
|
||||||
SemanticsFlag.isButton,
|
|
||||||
SemanticsFlag.hasEnabledState,
|
|
||||||
SemanticsFlag.isEnabled,
|
|
||||||
SemanticsFlag.isFocusable,
|
|
||||||
],
|
|
||||||
actions: <SemanticsAction>[SemanticsAction.tap],
|
actions: <SemanticsAction>[SemanticsAction.tap],
|
||||||
label: '4',
|
label: '4',
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
),
|
),
|
||||||
TestSemantics(
|
TestSemantics(
|
||||||
flags: <SemanticsFlag>[
|
flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
|
||||||
SemanticsFlag.isButton,
|
|
||||||
SemanticsFlag.hasEnabledState,
|
|
||||||
SemanticsFlag.isEnabled,
|
|
||||||
SemanticsFlag.isFocusable,
|
|
||||||
],
|
|
||||||
actions: <SemanticsAction>[SemanticsAction.tap],
|
|
||||||
label: '5',
|
|
||||||
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);
|
|
||||||
await tester.pumpWidget(
|
|
||||||
MaterialApp(
|
|
||||||
home: Material(
|
|
||||||
child: PopupMenuButton<int>(
|
|
||||||
itemBuilder: (BuildContext context) {
|
|
||||||
return <PopupMenuItem<int>>[
|
|
||||||
const PopupMenuItem<int>(value: 1, child: Text('1')),
|
|
||||||
const PopupMenuItem<int>(value: 2, enabled: false ,child: Text('2')),
|
|
||||||
const PopupMenuItem<int>(value: 3, child: Text('3')),
|
|
||||||
const PopupMenuItem<int>(value: 4, child: Text('4')),
|
|
||||||
const PopupMenuItem<int>(value: 5, child: Text('5')),
|
|
||||||
];
|
|
||||||
},
|
|
||||||
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: '1',
|
|
||||||
textDirection: TextDirection.ltr,
|
|
||||||
),
|
|
||||||
TestSemantics(
|
|
||||||
flags: <SemanticsFlag>[
|
|
||||||
SemanticsFlag.isButton,
|
|
||||||
SemanticsFlag.hasEnabledState,
|
|
||||||
],
|
|
||||||
actions: <SemanticsAction>[],
|
|
||||||
label: '2',
|
|
||||||
textDirection: TextDirection.ltr,
|
|
||||||
),
|
|
||||||
TestSemantics(
|
|
||||||
flags: <SemanticsFlag>[
|
|
||||||
SemanticsFlag.isButton,
|
|
||||||
SemanticsFlag.hasEnabledState,
|
|
||||||
SemanticsFlag.isEnabled,
|
|
||||||
SemanticsFlag.isFocusable,
|
|
||||||
],
|
|
||||||
actions: <SemanticsAction>[SemanticsAction.tap],
|
|
||||||
label: '3',
|
|
||||||
textDirection: TextDirection.ltr,
|
|
||||||
),
|
|
||||||
TestSemantics(
|
|
||||||
flags: <SemanticsFlag>[
|
|
||||||
SemanticsFlag.isButton,
|
|
||||||
SemanticsFlag.hasEnabledState,
|
|
||||||
SemanticsFlag.isEnabled,
|
|
||||||
SemanticsFlag.isFocusable,
|
|
||||||
],
|
|
||||||
actions: <SemanticsAction>[SemanticsAction.tap],
|
|
||||||
label: '4',
|
|
||||||
textDirection: TextDirection.ltr,
|
|
||||||
),
|
|
||||||
TestSemantics(
|
|
||||||
flags: <SemanticsFlag>[
|
|
||||||
SemanticsFlag.isButton,
|
|
||||||
SemanticsFlag.hasEnabledState,
|
|
||||||
SemanticsFlag.isEnabled,
|
|
||||||
SemanticsFlag.isFocusable,
|
|
||||||
],
|
|
||||||
actions: <SemanticsAction>[SemanticsAction.tap],
|
actions: <SemanticsAction>[SemanticsAction.tap],
|
||||||
label: '5',
|
label: '5',
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user