Repository navigation
[material_ui] Disable the DropdownButtonFormField decoration when the field is disabled - #13473
Conversation
… field is disabled The dropdown passed its input decoration to InputDecorator without setting enabled, so a disabled field kept its enabled colors and border and still reacted to hover. Mark the decoration disabled when the dropdown is, as TextField does. Fixes flutter/flutter#195192
There was a problem hiding this comment.
Code Review
This pull request updates DropdownButtonFormField to ensure its decoration is disabled when the field itself is disabled, preventing it from reacting to hover or using enabled colors. This is achieved by setting the enabled property of the InputDecoration in dropdown.dart. A regression test has been added to verify this behavior under different disabled states, along with a pending changelog entry. There are no review comments, so no additional feedback is provided.
QuncCccccc
left a comment
There was a problem hiding this comment.
LGTM! Thank you for the fix!
…n-form-field-disabled-decoration
|
The two red jobs here are |
flutter/packages@0478162...63881f9 2026-11-06 [email protected] [material_ui] Paint Dialog.fullscreen background color behind the keyboard (flutter/packages#13244) 2026-11-05 [email protected] [material_ui] Add tabBar/tab roles and expanded state semantics (flutter/packages#13176) 2026-11-05 [email protected] [material_ui] Disable the DropdownButtonFormField decoration when the field is disabled (flutter/packages#13473) 2026-11-05 [email protected] [material_ui] Fix Switch throwing when first painted mid-animation (flutter/packages#13496) 2026-11-05 [email protected] [various] Add engineIdentifier to fake plugin registrars (flutter/packages#13574) 2026-11-05 [email protected] [google_sign_in] Allow GoogleSignIn-iOS 10 (flutter/packages#13306) 2026-11-05 [email protected] [material_ui] Hit test the floating label of InputDecorator at its painted position (flutter/packages#13326) 2026-11-05 [email protected] [material_ui] Fix InputDecorator intrinsic height when isDense or isC… (flutter/packages#13522) 2026-11-05 [email protected] [material_ui] Paint Scaffold persistent bottom sheet background color behind the keyboard (flutter/packages#13242) 2026-11-05 [email protected] [image_picker_ios] PR 5/5 Switch Pigeon to Swift and finish the Objective-C to Swift migration. (flutter/packages#13493) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC [email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
DropdownButtonFormFieldpasses itsdecorationtoInputDecoratorthroughDropdownButton, but nothing set the decoration'senabled.InputDecoratoronly uses its disabled colors and borders, and only ignores hovering (isHoveringchecksdecoration.enabled), when the decoration is disabled. So a field disabled withenabled: false, or with a nullonChanged, kept its enabled border and fill and still changed color on hover. The selected item and the icon already turned grey, becauseDropdownButtonstyles those from its own enabled state.The fix sets
enabledon the decoration in_DropdownButtonState.buildfrom the dropdown's own enabled state.TextFielddoes the same before it builds itsInputDecorator, so a disabled dropdown and a disabled text field in the same form now look alike. A decoration passed in withenabled: falsestays disabled, as before.Tests
One regression test in
dropdown_form_field_test.dartchecks the decoration thatInputDecoratorgets: enabled with anonChanged, disabled withenabled: false, and disabled with noenabledand a nullonChanged. It fails onmainand passes with the fix.dropdown_form_field_test.dart,dropdown_test.dartandinput_decorator_test.dartall pass (724 tests), as does theshow_date_picker.2example test, which is the example that usesDropdownButtonFormField.Fixes flutter/flutter#195192
Pre-Review Checklist
[shared_preferences]///).I used AI tooling while working on this, and reviewed and tested all of it myself.
Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2