Repository navigation
fix: deliver dropdown on_change handlers the "change" event name - #65
Merged
Merged
Conversation
Since #28 a dropdown_m2 / dropdown on_change handler (or on(:change)) is stored under the canonical Dropdown "select" event, so it finally runs when the renderer fires "select". But it is called with that event as is, so event.name is "select" and legacy handler code that checks event.name == "change" stops matching. Wrap handlers registered under the Material 2 spelling (on_change:, on(:change), on(:on_change), attach_handler(:change)) so they are called with the same event renamed to "change". Only the name differs: target, control, page, raw_data, data, typed_data and value are the ones an on_select handler gets (new Event#with_name copies the event). Handlers registered with on_select still see "select", and the wire still carries on_select: true.
This was referenced Nov 6, 2026
AdamMusa
pushed a commit
that referenced
this pull request
Nov 7, 2026
Brings in #64 (reclaim only from child-control slots), #65 and #66 (Dropdown change event name and spellings) and #68 (inline date pickers in DSL blocks). Conflicts: - Page.presented_control?: #68 and this branch both exempt inline date pickers; kept this branch's inline_overlay? rule (any presented overlay built with inline: true), which #68's new tests also pass. - PropControls.reclaim: kept #64's child-slot walk and mounted-control rule together with this branch's last-first order; the comment covers both. Page#claim_prop_control now passes its value as a one-slot props hash, since reclaim reads props. - Dropdown contract and its test file: both sides' additions kept. ruflet_core 186/186 files (1039 runs), ruflet_rails 16/16, ruflet_record 5/5; ruflet_server and ruflet only the two environment-specific failures that also fail on main here. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MqfxcsDiEUZngybe9L72JQ
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.
Problem
Compatibility audit (v0.0.23
c1c366c9vs main61837818), dropdown section:#28 maps the Material 2 dropdown event onto the canonical Dropdown event:
dropdown_m2(on_change:),dropdownm2(on_change:),dropdown(on_change:)andon(:change)now store the handler under"select", and the wire carrieson_select: true. That part is right, because the Dropdown renderers only fireselect(enginematerial_dropdown.dart:315,cupertino_input_controls.dart). Before #28 these handlers never ran on a real client.But the handler is called with the client's event unchanged, so
event.nameis"select". Legacy handler code that checksevent.name == "change"no longer matches. Audit proberisk/probes/p04_dropdown.rb, calls recorded per handler as[handler, event.name]:on_change["m2.on_change","change"](only for a syntheticchange; the renderer'sselectnever reached it)["m2.on_change","change"],["m2.on_change","select"],["m2b.on_change","select"],["dd.on_change","select"]on_changecall sees"change"Why it matters for existing apps
The owner's rule is that this work must not change how developers write Ruflet apps.
dropdown_m2andon_changeare undocumented, but they are plausible in apps written against the Material 2 API. Handlers that branch onevent.name(a shared handler for several controls, or acase event.name) would run but take the wrong branch.Fix
In
PlatformControlContracts::Components::DropdownControl, a handler registered under the Material 2 spelling is wrapped when it is stored. That coverson_change:in the constructor or inmerge_props(throughpreprocess_props), pluson(:change),on(:on_change),on("change")andattach_handler(:change / :on_change). The wrapper calls it with the same event renamed to"change":"select", and the wire still sendson_select: true. Nothing changes on the protocol side.raw_data,data,typed_dataandvalueare the ones anon_selecthandler gets. The newRuflet::Event#with_name(name)makes the copy withdupplusinstance_variable_set, which is mruby-safe and already used inpage.rb.on_select:/on(:select)still see"select". Replacing anon_changehandler withon(:select)delivers"select".ControlDiffhandler copy keeps working.normalized_event_namenow reads the newMATERIAL2_EVENTStable instead of a hard-coded"change".Tests
packages/ruflet_core/test/dropdown_compatibility_test.rb, written first. On main's library code, 4 failures (14 runs, 118 assertions, 4 failures):test_dropdown_m2_on_change_fires_on_the_canonical_select_event: now expects[["change","blue"]]. It used to pin"select".test_dropdown_m2_change_handler_attached_later_fires_on_select:on(:change)sees"change".test_material2_change_handlers_see_change_while_on_select_handlers_see_select: 12 registration paths acrossdropdown,dropdown_m2anddropdownm2(constructor,onandattach_handler, each spelling).test_material2_change_handler_gets_the_same_event_data_as_an_on_select_handler: the sameraw_data,data,value,typed_dataclass,selection, control, page and target as anon_selecthandler.changeis still delivered as"change", and replacing the handler withon(:select)delivers"select".With the fix, all suites pass:
packages/ruflet_core,ruflet_server,rufletandruflet_rails, each file run on its own.The new DropdownControl and Event code was also run verbatim on the embedded VM (
tools/embedded_vm_harness/build/embedded_mruby --preload), on top of a copy ofControl's handler plumbing. Its output matched CRuby exactly.Doc harness
All 183 documented examples were run with the compat harness (
run.rb <worktree> <id>) and compared to the v0.0.23 baseline, ignoringtree_probe. The result is{"same" => 183}. No documented example changes, and none was meant to: the documented dropdown API ison_select.This PR and #66 (warn instead of raising on both spellings) both edit
DropdownControl#preprocess_props, in separate hunks. I test-merged the two on main: the merge is clean, the combined dropdown tests pass (16 runs), and the doc harness is still{"same" => 183}.