@@ -1701,6 +1701,55 @@ void main() {
1701
1701
expect (tester.takeException (), isNull);
1702
1702
});
1703
1703
1704
+ // Regression test for https://github.com/flutter/flutter/issues/165867.
1705
+ testWidgets ('Keyboard navigation only traverses filtered entries' , (WidgetTester tester) async {
1706
+ final TextEditingController controller = TextEditingController ();
1707
+ addTearDown (controller.dispose);
1708
+
1709
+ await tester.pumpWidget (
1710
+ MaterialApp (
1711
+ home: Scaffold (
1712
+ body: DropdownMenu <TestMenu >(
1713
+ requestFocusOnTap: true ,
1714
+ enableFilter: true ,
1715
+ controller: controller,
1716
+ dropdownMenuEntries: const < DropdownMenuEntry <TestMenu >> [
1717
+ DropdownMenuEntry <TestMenu >(value: TestMenu .mainMenu0, label: 'Good Match 1' ),
1718
+ DropdownMenuEntry <TestMenu >(value: TestMenu .mainMenu1, label: 'Bad Match 1' ),
1719
+ DropdownMenuEntry <TestMenu >(value: TestMenu .mainMenu2, label: 'Good Match 2' ),
1720
+ DropdownMenuEntry <TestMenu >(value: TestMenu .mainMenu3, label: 'Bad Match 2' ),
1721
+ DropdownMenuEntry <TestMenu >(value: TestMenu .mainMenu4, label: 'Good Match 3' ),
1722
+ DropdownMenuEntry <TestMenu >(value: TestMenu .mainMenu5, label: 'Bad Match 3' ),
1723
+ ],
1724
+ ),
1725
+ ),
1726
+ ),
1727
+ );
1728
+
1729
+ // Open the menu.
1730
+ await tester.tap (find.byType (DropdownMenu <TestMenu >));
1731
+ await tester.pump ();
1732
+
1733
+ // Filter the entries to only show the ones with 'Good Match'.
1734
+ await tester.enterText (find.byType (TextField ), 'Good Match' );
1735
+ await tester.pump ();
1736
+
1737
+ // Since the first entry is already highlighted, navigate to the second item.
1738
+ await tester.sendKeyEvent (LogicalKeyboardKey .arrowDown);
1739
+ await tester.pump ();
1740
+ expect (controller.text, 'Good Match 2' );
1741
+
1742
+ // Navigate to the third item.
1743
+ await tester.sendKeyEvent (LogicalKeyboardKey .arrowDown);
1744
+ await tester.pump ();
1745
+ expect (controller.text, 'Good Match 3' );
1746
+
1747
+ // Navigate back to the first item.
1748
+ await tester.sendKeyEvent (LogicalKeyboardKey .arrowDown);
1749
+ await tester.pump ();
1750
+ expect (controller.text, 'Good Match 1' );
1751
+ });
1752
+
1704
1753
// Regression test for https://github.com/flutter/flutter/issues/147253.
1705
1754
testWidgets ('Default search prioritises the current highlight' , (WidgetTester tester) async {
1706
1755
final ThemeData themeData = ThemeData ();
0 commit comments