Skip to content

fix: read Ruby keys in the Material 2 dropdown and form field decorations - #10

Merged
AdamMusa merged 3 commits into
codex/engine-initializationfrom
fix/dropdown-m2-wire
Oct 28, 2026
Merged

AdamMusa merged 3 commits into
codex/engine-initializationfrom
fix/dropdown-m2-wire

Conversation

@AdamMusa

@AdamMusa AdamMusa commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Fixes QA findings #6 (engine part) and #7. Companion Ruby PR: AdamMusa/ruflet#28 (same branch, fix/dropdown-m2-wire).

What was broken

  • material_dropdown_m2.dart read hint / disabled_hint, but Ruby sends hint_content / disabled_hint_content, so neither hint was ever drawn (fix: apply Ruby layout keywords to ReorderableDragHandle #7).
  • Its options were labelled with the option key instead of its text. The canonical and Cupertino dropdowns show text ?? key.
  • The shared buildInputDecoration read prefix_icon_constraints / suffix_icon_constraints. No Ruby control sends those keys: TextField, CupertinoTextField and DropdownM2 all send prefix_icon_size_constraints / suffix_icon_size_constraints. Both constraints were therefore dropped for Material TextField and DropdownM2.

Rendering after this PR

Wire type Material (Android, Windows, Linux, web) Cupertino (iOS, macOS)
DropdownM2 (legacy alias, still accepted) DropdownButtonFormField with hint_content and disabled_hint_content widgets. Selecting fires change with the value CupertinoTextField with a picker sheet and a text-only hint_text placeholder. Fires change (and select) with the value
Dropdown (what Ruby dropdown / dropdown_m2 / dropdownm2 send) DropdownMenu, fires select (unchanged) same Cupertino renderer, fires select (unchanged)

Documented as not honoured (code comments):

  • M2 renderer: text_vertical_align and fit_parent_size, because DropdownButtonFormField has no API for them.
  • M2 renderer: suffix_icon_size_constraints, because DropdownButton replaces the suffix constraints to align its select icon.
  • Cupertino: hint_content / disabled_hint_content. Cupertino placeholders are text only.

Decision: (b), keep Dropdown on the wire

I did not restore a DropdownM2 wire type from Ruby. The owner deliberately made it a protocol alias:

  • ruflet b9e52ff7 ("feat: unify platform controls in Ruby DSL") changed the DSL to def dropdown_m2(options = nil, **props) = dropdown(options, **props).
  • The same commit maps %w[dropdown dropdown_m2 dropdownm2] => Components::DropdownControl in platform_control_contracts.rb. Its KEYWORDS are the union of the Dropdown and DropdownM2 keywords.
  • The same commit added the test test_legacy_design_names_are_protocol_aliases_not_renderer_choices, which asserts Ruflet.dropdown_m2([]) emits "Dropdown".
  • This repo's models/control_type.dart lists "DropdownM2": "Dropdown" under "Legacy and transitional protocol names … Renderers must branch on platform, never on a Material/Cupertino wire name … new SDKs emit only the canonical names."

The Ruby PR therefore translates on_change to on_select (plus max_menu_height, prefix_icon and select_icon to their Dropdown spellings). With that, dropdownm2(on_change:) fires through the canonical select path on both designs. This PR only fixes the legacy DropdownM2 renderer, which older apps still reach, and the shared decoration keys. It adds no new type == branches.

Tests

New test/widgets/ruby_dropdown_m2_test.dart (7 tests). Its backend keeps the real on_<event> delivery gate:

  • DropdownM2 on Material: the hint_content widget shows, and option text (not key) is listed. Selecting "Blue" delivers [('change', 'blue')] and updates value. When disabled, the disabled_hint_content widget shows. prefix_icon_size_constraints reaches the decoration.
  • DropdownM2 on Cupertino: the hint_text placeholder shows, and picking "Blue" delivers [('change', 'blue')].
  • Dropdown as Ruby dropdown_m2 now sends it (on_select: true, menu_height), on Material and Cupertino: selecting delivers [('select', 'blue')], and menu_height is read.
  • Shared decoration: a Material TextField reads both *_icon_size_constraints keys.
  • On the base commit, 4 of the 7 fail (both hints and both constraint tests).

DropdownM2 is still served by the Dropdown createWidget case plus the raw-type branch, so control_renderer_matrix_test needs no new fixture.

Verification

verify_pr.sh <engine> <ruby> (Flutter 3.41.2, Ruby 4.0.5): RESULT: PASS

  • ruflet_core: 145/145 files, 623 runs (baseline 618)
  • engine packages/ruflet flutter test: +702, all passed (baseline 695)
  • flutter analyze lib test: no issues
  • wire-key audit: 0 new findings vs baseline. not-read 147 → 141, near-miss 43 → 36 (hint_content, disabled_hint_content and both *_icon_size_constraints now read)

The Material 2 renderer read `hint` and `disabled_hint`, but Ruby sends
`hint_content` and `disabled_hint_content`, so neither hint was ever drawn.
Options also showed their `key` instead of their `text`, unlike the
canonical and Cupertino dropdowns.

Document the Ruby keywords DropdownButtonFormField cannot honour, and that
Cupertino placeholders are text only.
Ruby TextField, CupertinoTextField and DropdownM2 send
`prefix_icon_size_constraints` and `suffix_icon_size_constraints`; the shared
input decoration read `prefix_icon_constraints` and `suffix_icon_constraints`,
which no Ruby control sends, so both constraints were dropped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant