Skip to content

Conversation

@HansMuller
Copy link
Contributor

@HansMuller HansMuller commented Aug 28, 2023

Fixes #126882

If the DropdownMenu's width is specified the menu items are now constrained to fit within the available horizontal space.

Added a labelWidget DropdownMenuEntry parameter to make it possible to override the automatically created label widget. By default the label widget is Text(label) which precludes configuring the Text widget with parameters like maxLines or overflow.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos labels Aug 28, 2023
@HansMuller HansMuller force-pushed the dropdown_menu_max_width branch 3 times, most recently from 3205856 to 24e2023 Compare August 28, 2023 22:45
Copy link
Contributor

@navaronbracke navaronbracke Aug 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we improve the required label later on? Somebody could now try to specify only labelWidget, but then they have to do label: '' as well. What if we have only a Widget label internally, and provide a .textLabel(String label) named constructor instead? (This is a breaking change though)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we always need a label, otherwise the search won't work, since the search always needs a text.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you made this a top level constant, you could access it from the test instead of duplicating it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When both label and labelWidget are specified, which one gets used for the semantics?

Copy link
Contributor Author

@HansMuller HansMuller Aug 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. The menu entry's MenuItemButton creates a TextButton which includes a container Semantics node, however the real semantics are provided by the labelWidget. So if your labelWidget doesn't include a Text widget or provide Semantics in some other way, then you've got an a11y problem. The same is true for all of the button classes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

Copy link
Member

@TahaTesser TahaTesser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@HansMuller HansMuller force-pushed the dropdown_menu_max_width branch from 54f603c to 9f6ec9d Compare August 29, 2023 18:29
@HansMuller HansMuller merged commit 4022864 into flutter:master Aug 29, 2023
Copy link
Contributor

@gspencergoog gspencergoog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

32384589-a60f0e74-c078-11e7-9bc1-e5b5287aea9d

@HansMuller HansMuller deleted the dropdown_menu_max_width branch August 29, 2023 21:19
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 30, 2023
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Aug 30, 2023
flutter/flutter@6c95737...1fe2495

2023-08-30 leroux_bruno@yahoo.fr Update SelectableRegion test for M3 (flutter/flutter#129627)
2023-08-30 godofredoc@google.com Remove cirrus tests from the flutter framework. (flutter/flutter#133575)
2023-08-30 engine-flutter-autoroll@skia.org Roll Flutter Engine from 749e67a947bc to 69f04bdfe952 (2 revisions) (flutter/flutter#133621)
2023-08-30 xilaizhang@google.com [flutter roll] Revert "Fix `Chip.shape`'s side is not used when provided in Material 3" (flutter/flutter#133615)
2023-08-30 engine-flutter-autoroll@skia.org Roll Flutter Engine from 9f2cf5c99b0f to 749e67a947bc (2 revisions) (flutter/flutter#133618)
2023-08-30 engine-flutter-autoroll@skia.org Roll Flutter Engine from c5854a6b3658 to 9f2cf5c99b0f (4 revisions) (flutter/flutter#133616)
2023-08-30 parlough@gmail.com No longer include `.packages` in created `.gitignore` files (flutter/flutter#133484)
2023-08-30 engine-flutter-autoroll@skia.org Roll Flutter Engine from db3ecf8b2739 to c5854a6b3658 (1 revision) (flutter/flutter#133610)
2023-08-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from 1feb9302050c to db3ecf8b2739 (4 revisions) (flutter/flutter#133609)
2023-08-29 polinach@google.com Fix one notDisposed leak and mark another. (flutter/flutter#133595)
2023-08-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from 01a1579808b5 to 1feb9302050c (1 revision) (flutter/flutter#133604)
2023-08-29 polinach@google.com Upgrade packages. (flutter/flutter#133593)
2023-08-29 polinach@google.com Cover more tests with leak tracking. (flutter/flutter#133596)
2023-08-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from 73cc3fb451fd to 01a1579808b5 (3 revisions) (flutter/flutter#133591)
2023-08-29 hans.muller@gmail.com Added DropdownMenuEntry.labelWidget (flutter/flutter#133491)
2023-08-29 ian@hixie.ch Use a fake stopwatch to remove flakiness. (flutter/flutter#133229)
2023-08-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from d1e6eb080f08 to 73cc3fb451fd (3 revisions) (flutter/flutter#133580)
2023-08-29 mdebbar@google.com [web] Migrate remaining web-only API usages to `dart:ui_web` (flutter/flutter#132248)
2023-08-29 gspencergoog@users.noreply.github.com Add doxygen doc generation. (flutter/flutter#131356)
2023-08-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from 50bd80773287 to d1e6eb080f08 (2 revisions) (flutter/flutter#133570)
2023-08-29 polinach@google.com ShortcutManager should dispatch creation in constructor. (flutter/flutter#133487)
2023-08-29 tessertaha@gmail.com Add FAB Additional Color Mappings example (flutter/flutter#133453)
2023-08-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from 65438c7bb46a to 50bd80773287 (1 revision) (flutter/flutter#133565)
2023-08-29 engine-flutter-autoroll@skia.org Roll Packages from 383bffa to d7d3150 (13 revisions) (flutter/flutter#133564)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC rmistry@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Material3] DropdownMenu Text Overflow

5 participants