Skip to content

[DropdownMenu] Disable text input  #116587

Closed

Description

@LasseRosenow

Kindly marking @QuncCccccc as I think the widget is developed by you? :)

In general the new DropDown menu is really good. I am happy to finally have a good and modern replacement for the old DropdownButton.

But I find that it's behavior to always open the keyboard even on mobile is a bit annoying especially in small menus with < 10 options to select from. There is no real benefits from opening the keyboard and it makes the user experience a bit worse by moving the menus around and massively reducing the screen space.

I think having the ability to use the keyboard in general is a good idea, especially with hardware keyboards, but on mobile it is a not so good default.

Example code

CLICK ME

import 'package:flutter/material.dart';

void main() => runApp(DropdownMenuExample());

class DropdownMenuExample extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(useMaterial3: true, colorSchemeSeed: Colors.green),
      home: const Scaffold(
        body: SafeArea(
          child: DropdownMenu<String>(
            initialSelection: "yellow",
            label: const Text('Color'),
            dropdownMenuEntries: [
              DropdownMenuEntry<String>(
                value: "red",
                label: "Red",
              ),
              DropdownMenuEntry<String>(
                value: "yellow",
                label: "Yellow",
              ),
              DropdownMenuEntry<String>(
                value: "green",
                label: "Green",
              ),
              DropdownMenuEntry<String>(
                value: "blue",
                label: "Blue",
              ),
              DropdownMenuEntry<String>(
                value: "purple",
                label: "Purple",
              ),
              DropdownMenuEntry<String>(
                value: "black",
                label: "Black",
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Possible solutions ordered by my preference:

a)

  • Disable the keyboard input on touch events.. only show on mouse click.
  • Add possibility to manually overwrite this behavior with some flag

b)

  • Disable the keyboard input for small lists (< 10 items)
  • Add possibility to manually overwrite this behavior with some flag

c)

  • keep as is, but enable possibility to manually overwrite this his behavior with some flag

Activity

  1. added
    in triagePresently being triaged by the triage team
    on Dec 6, 2022
  2. exaby73 commented on Dec 6, 2022

    @exaby73
    Member

    Hello @LasseRosenow. Thank you for filing this issue. Can you please provide the following information?

    Please provide the information in the form of text. See how to make collapsible sections with Markdown here.

    PS: Kindly refrain from mentioning team members. I know you have good intentions but as a best practice, it's better allow the team to look at this issue once it's triaged, which is why I am here :)

  3. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Dec 6, 2022
  4. LasseRosenow commented on Dec 6, 2022

    @LasseRosenow
    ContributorAuthor

    Thank you for your quick response. And sorry for the ping, I will not do it again :)

    So I added a minimal example that should be enough to show the issue.

  5. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Dec 6, 2022
  6. exaby73 commented on Dec 7, 2022

    @exaby73
    Member

    As per the documentation:

    A dropdown menu that can be opened from a TextField. The selected menu item is displayed in that field.

    This is meant to be a "searchable" TextField. I think for your usecase, DropdownButton makes more sense. Since there is already a widget that provides a dropdown without text input, it doesn't make sense to change this widget as DropdownMenu is not a replacement for DropdownButton.

    Due to the above reasons, I do not think this issue is valid, and therefore I am closing this issue. If you disagree, please comment with your reasoning and I can reopen it. Thank you

  7. added
    r: invalidIssue is closed as not valid
    and removed
    in triagePresently being triaged by the triage team
    on Dec 7, 2022
  8. LasseRosenow commented on Dec 7, 2022

    @LasseRosenow
    Author
  9. LasseRosenow commented on Dec 7, 2022

    @LasseRosenow
    ContributorAuthor

    I don't agree.

    The material design specification does not have a drop-down button. In the material 4 Specification everything is a menu and should use the menu internally.

    The flutter drop-down button implementation is a mess as it draws it's own menu instead of reusing the menu widget internally like the new DropdownButton does.

    Drop-down button also had a version that could be used inside a text field. I am really certain that this is indeed a replacement of that version. Also based on some discussion I was following on GitHub.

    The material 3 documentation says, that a menu can be triggered by a text field. That this text field must be usable by the keyboard is "unspecified".

    The native android components don't open the keyboard. See the Google contact app for example, so this new experience feels awkward inside the android material design ecosystem.

    Screenshot_20221207-121024_Kontakte.png

    PS: you see in #115005 that the author clearly states, that DropdownMenu is an update to the DropdownButton. I am sure, that DropdownButton will be deprecated in time as it should.

  10. LasseRosenow commented on Dec 7, 2022

    @LasseRosenow
    ContributorAuthor

    Okay I spend some more time reading the material design 3 guidelines and actually find proof that the guidelines would not show the keyboard on touch by default. Because every example video does not.

    Like this for example:

    l01ijuvs-menu_usage_3P_2.mp4

    Source: https://m3.material.io/components/menus/guidelines

  11. LasseRosenow commented on Dec 7, 2022

    @LasseRosenow
    ContributorAuthor

    In general it seems that this "filtering" is more a special use case as the specification speaks about it:
    grafik

  12. exaby73 commented on Dec 7, 2022

    @exaby73
    Member

    Thanks for the information :) I will label this issue for further insights and discussion from the team

  13. reopened this on Dec 7, 2022
  14. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    r: invalidIssue is closed as not valid
    on Dec 7, 2022
  15. added
    r: fixedIssue is closed as already fixed in a newer version
    on Jan 30, 2023
  16. github-actions commented on Mar 3, 2023

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  17. locked as resolved and limited conversation to collaborators on Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

found in release: 3.3Found to occur in 3.3found in release: 3.7Found to occur in 3.7frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions