@@ -2442,6 +2442,7 @@ void main() {
24422442 MaterialApp (
24432443 home: Scaffold (
24442444 body: DropdownMenu <String >(
2445+ requestFocusOnTap: true ,
24452446 controller: controller,
24462447 dropdownMenuEntries: const < DropdownMenuEntry <String >> [
24472448 DropdownMenuEntry <String >(
@@ -2675,6 +2676,53 @@ void main() {
26752676 expect (find.widgetWithText (MenuItemButton , menu.label), findsNWidgets (2 ));
26762677 }
26772678 });
2679+
2680+ // This is a regression test for https://github.com/flutter/flutter/issues/151686.
2681+ testWidgets ('Setting DropdownMenu.requestFocusOnTap to false makes TextField read only' , (WidgetTester tester) async {
2682+ const String label = 'Test' ;
2683+ Widget buildDropdownMenu ({ bool ? requestFocusOnTap }) {
2684+ return MaterialApp (
2685+ home: Scaffold (
2686+ body: Center (
2687+ child: DropdownMenu <TestMenu >(
2688+ requestFocusOnTap: requestFocusOnTap,
2689+ dropdownMenuEntries: menuChildren,
2690+ hintText: label,
2691+ ),
2692+ ),
2693+ ),
2694+ );
2695+ }
2696+ await tester.pumpWidget (buildDropdownMenu (requestFocusOnTap: true ));
2697+
2698+ expect (
2699+ tester.getSemantics (find.byType (TextField )),
2700+ matchesSemantics (
2701+ hasFocusAction: true ,
2702+ hasTapAction: true ,
2703+ isTextField: true ,
2704+ hasEnabledState: true ,
2705+ isEnabled: true ,
2706+ label: 'Test' ,
2707+ textDirection: TextDirection .ltr,
2708+ ),
2709+ );
2710+
2711+ await tester.pumpWidget (buildDropdownMenu (requestFocusOnTap: false ));
2712+
2713+ expect (
2714+ tester.getSemantics (find.byType (TextField )),
2715+ matchesSemantics (
2716+ hasFocusAction: true ,
2717+ isTextField: true ,
2718+ hasEnabledState: true ,
2719+ isEnabled: true ,
2720+ label: 'Test' ,
2721+ isReadOnly: true ,
2722+ textDirection: TextDirection .ltr,
2723+ ),
2724+ );
2725+ });
26782726}
26792727
26802728enum TestMenu {
0 commit comments