Repository navigation
fix: translate dropdown_m2 events and keys onto the canonical Dropdown - #28
Merged
Merged
Conversation
dropdown_m2 has emitted the canonical Dropdown since b9e52ff, but its `on_change` handler was registered for a "change" event that the Dropdown renderers never fire (they fire "select"), so it never ran on any platform. Rename the Material 2 spellings that have a Dropdown equivalent (on_change, max_menu_height, prefix_icon, select_icon) to the keys both renderers read, map later `on(:change)` handlers to "select", and list the Material 2 keywords the Dropdown renderers do not draw.
This was referenced Nov 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes QA finding #6. Companion engine PR: AdamMusa/ruflet-engine#10 (same branch,
fix/dropdown-m2-wire).The bug
Since b9e52ff,
dropdown,dropdown_m2anddropdownm2all buildPlatformControlContracts::Components::DropdownControland send"_c": "Dropdown". That contract accepts the union of the Dropdown and Material 2 keywords. Sodropdownm2(on_change: h)was accepted, but it registered a"change"handler and senton_change: true. Both Dropdown renderers fire"select"(Materialmaterial_dropdown.dart:315, Cupertinocupertino_input_controls.dart:118), so the handler never ran on any platform. Material 2 spellings such asmax_menu_heightandselect_iconwere also sent under keys the Dropdown renderers don't read.Decision: (b), keep the canonical
Dropdownwire type and translateThe owner deliberately routed DropdownM2 onto the canonical Dropdown, so restoring a
DropdownM2wire type (option a) would undo his design:def dropdown_m2(options = nil, **props) = dropdown(options, **props). It also mapped%w[dropdown dropdown_m2 dropdownm2] => Components::DropdownControlinplatform_control_contracts.rb, whose header says the schemas "deliberately accept the union of the Material and Cupertino properties: Ruby describes intent and the platform renderer decides how that intent looks".test_legacy_design_names_are_protocol_aliases_not_renderer_choices, assertingRuflet.dropdown_m2([])emits"Dropdown". Nearby comments say so too: "Compatibility aliases only. They emit the same canonical wire types … and never select the visual renderer" (control_methods.rb) and "There is no design-system choice in this API" (platform_control_methods.rb)."DropdownM2": "Dropdown"sits incontrol_type.dartunder "Legacy and transitional protocol names … new SDKs emit only the canonical names".Dropdown2Control(WIRE = "Dropdown") can't be reached from the DSL at all. Option (a) would have meant reverting the class map, the DSL method and the owner's test.The fix follows the owner's later contract fix 34f95e7 ("fix: preserve typed dates in canonical picker DSL"): it normalizes inside the platform contract.
Change
Components::DropdownControl(used bydropdown,dropdown_m2,dropdownm2):MATERIAL2_RENAMES:on_change → on_select,max_menu_height → menu_height,prefix_icon → leading_icon,select_icon → trailing_icon. These are exact equivalents read by the Dropdown renderers. Passing a Material 2 key together with its Dropdown spelling raisesArgumentError.normalized_event_namemapschangetoselect, soon(:change) { },has_handler?(:change)andemit("change")work too. The handler receives theselectevent (event.name == "select",event.valueis the chosen key).MATERIAL2_UNSUPPORTED_KEYWORDSexplicitly documents the other 35 Material 2 keywords. They are still accepted and sent, so existingdropdown_m2code keeps loading, but neither Dropdown renderer draws them (andon_clicknever fires):align_label_with_hint alignment collapsed counter counter_style disabled_hint_content enable_feedback error error_max_lines fit_parent_size focus_color focused_bgcolor focused_color helper helper_max_lines hint_content hint_fade_duration hint_max_lines icon item_height options_fill_horizontally padding prefix prefix_icon_size_constraints prefix_style select_icon_disabled_color select_icon_enabled_color select_icon_size size_constraints suffix suffix_icon suffix_icon_size_constraints suffix_style text_vertical_align on_click. A test keeps this list plus the renames equal toDropdown2Control::KEYWORDS - DropdownControl::KEYWORDS.KEYWORDS are unchanged.
Tests
dropdown_compatibility_test.rb, 5 new tests:on_changefires on a dispatchedselect, updatesvalue, and sendson_select(noton_change).on(:change)fires onselect.control_coverage_test.rbtest_dropdown_m2_serializes_options_and_valuenow also asserts theon_changehandler is registered,on_selectis on the wire, andhint_content/max_menu_heightserialize.platform_control_contract_test.rbis unchanged and still passes (dropdown_m2emitsDropdown).Verification
verify_pr.sh <engine> <ruby>(Flutter 3.41.2, Ruby 4.0.5): RESULT: PASSflutter test: +702, all passed (baseline 695)flutter analyze lib test: no issues