AhmedLSayed9 / dropdown_button2

Flutter's core Dropdown Button widget with steady dropdown menu and many other features.
https://pub.dev/packages/dropdown_button2
MIT License
270 stars 124 forks source link

Request for Dropdown Menu Auto-Close Feature on Screen Size Change #326

Open NaderMohamedMusa opened 1 week ago

NaderMohamedMusa commented 1 week ago

Hi Ahmed,

I've encountered an issue in our Flutter web project while using the DropdownButtonFormField2 package. Specifically, I need the dropdown menu to automatically close when the screen size changes. Currently, this behavior is not supported by the package.

I implemented a temporary workaround using WidgetsBindingObserver to detect screen size changes and close the menu manually via Navigator.of(context).pop(). However, it would be more efficient if this feature were supported natively by the package.

I've drafted a request to raise this issue with the package maintainer and included the relevant code. If you agree, I can proceed with contacting the maintainer.

Looking forward to your feedback. dropDownButton2_issues.txt

Thanks!

AhmedLSayed9 commented 1 week ago

The common practice for dropdown menus in web is to remain open until the user interacts with them (e.g., by clicking outside the menu or choosing an option).

Auto closing the menu when the screen size changes can be disruptive to the user experience. Can you elaborate more why it is needed?

NaderMohamedMusa commented 5 days ago

Hello,

Thank you for your recent update. I noticed that the latest beta version of the package has resolved some of the issues I was facing with dropdown functionality. However, I would like to suggest adding a field or property that controls whether the dropdown menu should remain open or close when the web screen size changes.

This feature would provide more flexibility for developers working on responsive web applications, allowing them to manage dropdown visibility effectively without needing to implement custom listeners.

Please let me know if this is something that can be considered in future releases.

Thank you for your continuous support and efforts!

AhmedLSayed9 commented 5 days ago

Closing dropdown menu when the screen size changes is uncommon practice and can be opinionated.

i.e: a user may want it to close just when screen size changes and another user may want it to close at some breakpoints. another example: a user may want it to close when keyboard opens, another user doesn't (using search dropdown).

Therefore, as this is uncommon practice and can be easily done by using Navigator.of(context).pop(), I don't think it's a good idea to implement it internally.