Repository navigation
DropdownMenu filtering is broken (after selecting an item, it reverts to a different value) #174609
Copy link
Copy link
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: regressionIt was better in the past than it is nowIt was better in the past than it is nowfound in release: 3.35Found to occur in 3.35Found to occur in 3.35found in release: 3.36Found to occur in 3.36Found to occur in 3.36frameworkflutter/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 teamworkaround availableThere is a workaround available to overcome the issueThere is a workaround available to overcome the issue
Description
Steps to reproduce
- Run the code sample below (it works in dartpad).
- Click the text field.
- Type "a".
- Select the third option, "Dragonfruit".
Expected results
It should say "Dragonfruit".
Actual results
It says "Cherry"!
Code sample
import 'package:flutter/material.dart';
void main() {
runApp(const DropdownMenuExample());
}
final List<DropdownMenuEntry<String>> entries = [
DropdownMenuEntry<String>(value: 'Apple', label: 'Apple'),
DropdownMenuEntry<String>(value: 'Banana', label: 'Banana'),
DropdownMenuEntry<String>(value: 'Cherry', label: 'Cherry'),
DropdownMenuEntry<String>(value: 'Dragonfruit', label: 'Dragonfruit'),
];
class DropdownMenuExample extends StatefulWidget {
const DropdownMenuExample({super.key});
@override
State<DropdownMenuExample> createState() => _DropdownMenuExampleState();
}
class _DropdownMenuExampleState extends State<DropdownMenuExample> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Material(
child: DropdownMenu<String>(
enableFilter: true,
onSelected: (String? icon) {
setState(() { });
},
dropdownMenuEntries: entries.toList(),
),
),
);
}
}This regressed in #162062.
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 listc: regressionIt was better in the past than it is nowIt was better in the past than it is nowfound in release: 3.35Found to occur in 3.35Found to occur in 3.35found in release: 3.36Found to occur in 3.36Found to occur in 3.36frameworkflutter/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 teamworkaround availableThere is a workaround available to overcome the issueThere is a workaround available to overcome the issue
Activity
pranataprojects commentedon Aug 28, 2025
Hi @Hixie , I ran into the same issue and found a workaround. The problem is that
DropdownMenudoesn’t consistently keep the selected value after filtering unless you manage the selection explicitly.You can fix it by holding the current selection in state and passing it back to the widget via
initialSelection.For example:With this, selecting “Dragonfruit” will remain stable instead of reverting to “Cherry.”
tirth-patel-nc commentedon Aug 28, 2025
@Hixie Thanks for the report. Seeing the same behaviour with latest SDK versions with provided code sample & steps. It doesn't replicate on 3.32.8 hence marking it as a regression.
@pranataprojects thanks for the workaround.
3.32.8 (WAI)
Screen.Recording.2025-08-28.at.5.18.17.PM.mov
3.35.2, 3.36.0-1.0.pre-305 (Issue)
Screen.Recording.2025-08-28.at.5.17.39.PM.mov
ahmedrasar commentedon Aug 30, 2025
I filed a fix in #174757.
I had to work around some edgy use cases in the original PR, I must have been consumed so that little detail have slipped by. Sorry for that.
Fix DropdownMenu filtering is broken (#177450)
github-actions commentedon Nov 10, 2025
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.