• Taha Tesser's avatar
    Fix disabled `DropdownMenu` doesn't defer the mouse cursor (#145686) · d2c85529
    Taha Tesser authored
    fixes [DropdownMenu cursor in disabled state](https://github.com/flutter/flutter/issues/144611)
    
    This was added in https://github.com/flutter/flutter/pull/121353
    
    ### Code sample
    
    <details>
    <summary>expand to view the code sample</summary> 
    
    ```dart
    import 'package:flutter/material.dart';
    
    void main() {
      runApp(const MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({super.key});
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          debugShowCheckedModeBanner: false,
          home: Scaffold(
            body: Center(
              child: Column(
                mainAxisSize: MainAxisSize.min,
                children: <Widget>[
                  const Spacer(),
                  const Text('enabled: true,\nrequestFocusOnTap: true,'),
                  const SizedBox(height: 16),
                  DropdownMenu<String>(
                    enabled: true,
                    initialSelection: 'First',
                    requestFocusOnTap: true,
                    width: 200,
                    dropdownMenuEntries: ['First', 'Second', 'Third']
                        .map((e) => DropdownMenuEntry(value: e, label: e))
                        .toList(),
                  ),
                  const Text('Expected: text cursor'),
                  const Spacer(),
                  const Text('enabled: true,\nrequestFocusOnTap: false,'),
                  const SizedBox(height: 16),
                  DropdownMenu<String>(
                    enabled: true,
                    initialSelection: 'First',
                    requestFocusOnTap: false,
                    width: 200,
                    dropdownMenuEntries: ['First', 'Second', 'Third']
                        .map((e) => DropdownMenuEntry(value: e, label: e))
                        .toList(),
                    // label: const Text('requestFocusOnTap: false'),
                  ),
                  const Text('Expected: clickable cursor'),
                  const Spacer(),
                  const Text('enabled: false,\nrequestFocusOnTap: true,'),
                  const SizedBox(height: 16),
                  DropdownMenu<String>(
                    enabled: false,
                    initialSelection: 'First',
                    requestFocusOnTap: true,
                    width: 200,
                    dropdownMenuEntries: ['First', 'Second', 'Third']
                        .map((e) => DropdownMenuEntry(value: e, label: e))
                        .toList(),
                  ),
                  const Text('Expected: deferred cursor'),
                  const Spacer(),
                  const Text('enabled: false,\nrequestFocusOnTap: false,'),
                  const SizedBox(height: 16),
                  DropdownMenu<String>(
                    enabled: false,
                    initialSelection: 'First',
                    requestFocusOnTap: false,
                    width: 200,
                    dropdownMenuEntries: ['First', 'Second', 'Third']
                        .map((e) => DropdownMenuEntry(value: e, label: e))
                        .toList(),
                  ),
                  const Text('Expected: deferred cursor'),
                  const Spacer(),
                ],
              ),
            ),
          ),
        );
      }
    }
    ```
    
    </details>
    
    ### Preview
    ![Screenshot 2024-03-25 at 14 52 31](https://github.com/flutter/flutter/assets/48603081/cf4361a5-d3bb-4635-9825-5eefa4efe6cc)
    d2c85529
Name
Last commit
Last update
..
flutter Loading commit data...
flutter_driver Loading commit data...
flutter_goldens Loading commit data...
flutter_localizations Loading commit data...
flutter_test Loading commit data...
flutter_tools Loading commit data...
flutter_web_plugins Loading commit data...
fuchsia_remote_debug_protocol Loading commit data...
integration_test Loading commit data...
analysis_options.yaml Loading commit data...