Repository navigation
DropdownMenu does not correctly handle incoming maxWidth and minHeight constraints #147076
Copy link
Copy link
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.19Found to occur in 3.19Found to occur in 3.19found in release: 3.22Found to occur in 3.22Found to occur in 3.22frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Description
Consider the following demo:
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(
title: 'Flutter Demo',
home: Container(
alignment: Alignment.center,
color: Colors.amber,
child: SizedBox(
height: 100.0,
width: 100.0,
child: Card(
child: DropdownMenu(
dropdownMenuEntries: [
DropdownMenuEntry(
value: '',
label: 'This is a very long label',
),
],
),
),
),
),
);
}
}It should display a 100x100 widget, or at least a widget not wider than 100 pixels, whose menu appears below it.
Instead it displays a widget that is wider than the maxWidth (painting outside of its allowed bounds), and the menu renders below the minHeight, not under the actual widget:
The width aspect of this in particular is quite serious as it makes it impossible to use this widget with user-controlled text without risking overflow. You can't even set a labelWidget that makes the text wrap or truncate, because the labels don't receive the constraints.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.19Found to occur in 3.19Found to occur in 3.19found in release: 3.22Found to occur in 3.22Found to occur in 3.22frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Type
Projects
- StatusShow more project fieldsDone (PR merged)

Activity
danagbemava-nc commentedon Apr 22, 2024
Reproducible using the code sample provided above.
flutter doctor -v
PurplePolyhedron commentedon Apr 22, 2024
For the width overflow, it seems to be cause by the textfield not constraint by the widget constraint here link
I made a draft fix, but haven't figure out the test yet ffa54dd
bleroux commentedon Apr 23, 2024
@PurplePolyhedron
Great! Looks like you found one root cause of this issue which seems to be
getMaxIntrinsicWidthbeing called withwidthas a parameter instead ofheightand similar problem withgetMaxIntrinsicHeight.Are you interested in filing a PR?
I assigned you for the moment and I can help to review/write test.
PurplePolyhedron commentedon Apr 23, 2024
Thanks, I will try to file a PR soon.
PurplePolyhedron commentedon Apr 23, 2024
@bleroux I've filed an PR and written some tests. Let me know if it need more tests or any changes.
2 remaining items
fix DropdownMenu overflow (#147233)
flutter-triage-bot commentedon Aug 28, 2024
This issue is assigned to @PurplePolyhedron but has had no recent status updates. Please consider unassigning this issue if it is not going to be addressed in the near future. This allows people to have a clearer picture of what work is actually planned. Thanks!
Fix DropdownMenu menu is detached from the text field (#159665)
github-actions commentedon Dec 18, 2024
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 -vand a minimal reproduction of the issue.