Skip to content

fix: deliver legacy DropdownM2 change through the alias table - #100

Merged
AdamMusa merged 1 commit into
codex/engine-initializationfrom
fix/ios-dropdown-dead-change
Nov 2, 2026
Merged

AdamMusa merged 1 commit into
codex/engine-initializationfrom
fix/ios-dropdown-dead-change

Conversation

@AdamMusa

Copy link
Copy Markdown
Owner

Legacy-renderer fix in the same class as #93: it removes a renderer branch on a wire name. It is not part of the control-core stack and has no dependencies. It needs no Ruby change.

Finding: the branch was not dead

cupertino_input_controls.dart fired an extra event for one wire name:

control.triggerEvent("select", value);
if (control.type == "DropdownM2") control.triggerEvent("change", value);
  • Current Ruby never reaches it. dropdown, dropdown_m2 and dropdownm2 have all sent the canonical Dropdown wire type since b9e52ff7 (released in v0.0.22). Since ruflet#28, dropdown_m2(on_change:) is sent as on_select and Ruby routes the select event to that handler (test_dropdown_m2_on_change_fires_on_the_canonical_select_event). So the canonical select path covers it.
  • Published gems up to v0.0.21 still send _c: "DropdownM2" with on_change. ruflet build fetches the template live, so those apps run this engine.
    • On iOS, this line was the only thing that delivered their on_change.
    • On Android, dropdown.dart renders the Material 2 widget for that wire, which fires change itself.
    • The base's own test, Cupertino shows the hint placeholder and fires change, pins that iOS behaviour.

Deleting the line would therefore have silently dropped on_change on iOS for those apps while Android kept it. That conflicts with "aliases keep old wire names working" (DECOUPLING_SPEC §5.1, DC-7) and DC-5 (never remove a capability). So this PR fixes the branch rather than deleting it.

Fix

  • Renderer: the Cupertino dropdown fires only the canonical select, and no longer looks at the wire name.
  • Alias table: control_type.dart gains a legacy event table next to the alias map: DropdownM2 → {select: change}. It lists the name under which a legacy alias subscribes to a canonical event.
  • Gate: RufletBackend.triggerControlEvent, the one place that checks on_<event>, translates the name through that table before checking. The legacy wire keeps receiving change, and every other type is untouched (an identity lookup).
  • Migrated controls: they go through the same gate (ControlEvents → Control.triggerEvent). So once Dropdown is migrated, its core fires only select and old clients still work.

The edits stay clear of open PRs:

Not changed here: dropdown.dart still picks the Material 2 widget from control.type == "DropdownM2". That is the same class of branch, but it chooses a look for a wire that only pre-v0.0.22 gems send. Removing it is a decision for the Dropdown migration.

Related, not fixed here: gems v0.0.22 and v0.0.23 send dropdown_m2(on_change:) as _c: "Dropdown" with on_change: true. No renderer fires change for the canonical type, so that handler never runs on either design. ruflet#28 fixes this in Ruby, but it is not yet released.

Tests

test/utils/control_type_test.dart (+1): the legacy event table maps DropdownM2 select → change and leaves other events and types unchanged.

test/widgets/ruby_dropdown_m2_test.dart (+2). The backend now records every event a renderer fires before the on_<event> gate.

  • Legacy DropdownM2 on iOS: the renderer fires select and never change, and Ruby receives change "blue". The existing fires change test is unchanged and still passes.
  • iOS, the exact wire ruflet main sends for dropdown_m2(on_change:, max_menu_height: 200) (_c: "Dropdown", on_select: true): Ruby receives one select "blue" and no change.

Mutation checks (each makes these tests fail):

  • removing the gate's translation (the two legacy iOS tests fail);
  • restoring the wire-name branch (the double delivery fails the new assertions).

team/verify_pr.sh (ruflet main as the Ruby tree): PASS.

  • ruflet_core 166/166 files (772 runs).
  • engine flutter test +1204, analyze clean.
  • Wire-key audit: 0 new findings.

The Cupertino dropdown branched on the DropdownM2 wire name to fire an
extra `change` event. Current Ruby never sends that wire (dropdown_m2 has
emitted the canonical Dropdown with on_select since b9e52ff7), but gems up
to v0.0.21 still do, with on_change, and the template is fetched live.

Renderers now fire only the canonical `select`; a control_type.dart table
records that the legacy DropdownM2 alias subscribes to it as `change`, and
the backend's on_<event> gate delivers it under that name. Old clients keep
their on_change on iOS, with no wire-name branch in the renderer.
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