From 067d3da827d2e25a01ca1a05903da3a996b04fd8 Mon Sep 17 00:00:00 2001 From: chunhtai <47866232+chunhtai@users.noreply.github.com> Date: Mon, 13 Jul 2020 12:24:42 -0700 Subject: [PATCH] Revert "Adds semantics information for the popup menu item (#61258)" (#61377) This reverts commit c6058df9ca8e871772c4a0444cff43690e33cb0d. --- .../flutter/lib/src/material/popup_menu.dart | 14 +- .../test/material/popup_menu_test.dart | 154 +----------------- 2 files changed, 10 insertions(+), 158 deletions(-) diff --git a/packages/flutter/lib/src/material/popup_menu.dart b/packages/flutter/lib/src/material/popup_menu.dart index 3b2ecfbde7..2e40407312 100644 --- a/packages/flutter/lib/src/material/popup_menu.dart +++ b/packages/flutter/lib/src/material/popup_menu.dart @@ -342,15 +342,11 @@ class PopupMenuItemState> extends State { }, ); - return Semantics( - enabled: widget.enabled, - button: true, - child: InkWell( - onTap: widget.enabled ? handleTap : null, - canRequestFocus: widget.enabled, - mouseCursor: effectiveMouseCursor, - child: item, - ), + return InkWell( + onTap: widget.enabled ? handleTap : null, + canRequestFocus: widget.enabled, + mouseCursor: effectiveMouseCursor, + child: item, ); } } diff --git a/packages/flutter/test/material/popup_menu_test.dart b/packages/flutter/test/material/popup_menu_test.dart index a17845c1cf..db67c1a755 100644 --- a/packages/flutter/test/material/popup_menu_test.dart +++ b/packages/flutter/test/material/popup_menu_test.dart @@ -765,175 +765,31 @@ void main() { ], children: [ TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], + flags: [SemanticsFlag.isFocusable], actions: [SemanticsAction.tap], label: '1', textDirection: TextDirection.ltr, ), TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], + flags: [SemanticsFlag.isFocusable], actions: [SemanticsAction.tap], label: '2', textDirection: TextDirection.ltr, ), TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], + flags: [SemanticsFlag.isFocusable], actions: [SemanticsAction.tap], label: '3', textDirection: TextDirection.ltr, ), TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], + flags: [SemanticsFlag.isFocusable], actions: [SemanticsAction.tap], label: '4', textDirection: TextDirection.ltr, ), TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], - actions: [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( - itemBuilder: (BuildContext context) { - return >[ - const PopupMenuItem(value: 1, child: Text('1')), - const PopupMenuItem(value: 2, enabled: false ,child: Text('2')), - const PopupMenuItem(value: 3, child: Text('3')), - const PopupMenuItem(value: 4, child: Text('4')), - const PopupMenuItem(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( - textDirection: TextDirection.ltr, - children: [ - TestSemantics( - children: [ - TestSemantics( - flags: [ - SemanticsFlag.scopesRoute, - SemanticsFlag.namesRoute, - ], - label: 'Popup menu', - textDirection: TextDirection.ltr, - children: [ - TestSemantics( - flags: [ - SemanticsFlag.hasImplicitScrolling, - ], - children: [ - TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], - actions: [SemanticsAction.tap], - label: '1', - textDirection: TextDirection.ltr, - ), - TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - ], - actions: [], - label: '2', - textDirection: TextDirection.ltr, - ), - TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], - actions: [SemanticsAction.tap], - label: '3', - textDirection: TextDirection.ltr, - ), - TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], - actions: [SemanticsAction.tap], - label: '4', - textDirection: TextDirection.ltr, - ), - TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], + flags: [SemanticsFlag.isFocusable], actions: [SemanticsAction.tap], label: '5', textDirection: TextDirection.ltr,