• 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
.github Loading commit data...
.vscode Loading commit data...
bin Loading commit data...
dev Loading commit data...
examples Loading commit data...
packages Loading commit data...
.ci.yaml Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CODEOWNERS Loading commit data...
CODE_OF_CONDUCT.md Loading commit data...
CONTRIBUTING.md Loading commit data...
LICENSE Loading commit data...
PATENT_GRANT Loading commit data...
README.md Loading commit data...
TESTOWNERS Loading commit data...
analysis_options.yaml Loading commit data...
dartdoc_options.yaml Loading commit data...
flutter_console.bat Loading commit data...