Repository navigation
fix: warn instead of raising when a dropdown gets both key spellings - #66
Merged
Merged
Conversation
Since #28, passing a Material 2 dropdown key together with its Dropdown spelling (on_change: with on_select:, max_menu_height: with menu_height:, prefix_icon: with leading_icon:, select_icon: with trailing_icon:) raises ArgumentError. That code loaded in v0.0.23, so an app that passed both now fails to build its view. Warn once per pair with Kernel.warn (mruby-safe, as elsewhere in ruflet_core) and keep the Dropdown key; the Material 2 value is dropped. A lone key of either spelling is unchanged and does not warn.
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 renames the Material 2 dropdown keys onto the Dropdown contract:
on_changebecomeson_select,max_menu_heightbecomesmenu_height,prefix_iconbecomesleading_iconandselect_iconbecomestrailing_icon. When a call passes a Material 2 key together with its Dropdown key, it now raises:Audit evidence (
surface/behavior_probe.rbP2/P3b,risk/probes/p04_dropdown.rb):dropdown(on_select: a, on_change: b)loaded and sent{"on_change"=>true,"on_select"=>true}.ArgumentError, and so doesdropdown(prefix_icon:, leading_icon:).Why it matters for existing apps
The owner's rule is that this work must not change how developers write Ruflet apps. An app that passed both spellings (common when porting Material 2 code by adding the new key without deleting the old one) loaded on v0.0.23. On main it raises while it builds the view, so the whole page fails, not just the dropdown.
Fix
In
DropdownControl#preprocess_props, when both spellings of a pair are present the code now callsKernel.warnand drops the Material 2 value.Kernel.warnis the mruby-safe form already used inpage.rbandcontrol.rb. The warning reads:on_selecthandler is the one that runs, both for the renderer'sselectand for achange.Tests
packages/ruflet_core/test/dropdown_compatibility_test.rb, written first. On main's library code, 2 errors (ArgumentError ... not both):test_dropdown_m2_warns_and_keeps_the_dropdown_key_when_both_spellings_are_given: exactly one warning naming:on_selectand:on_change. The wire hason_select: trueand noon_change. Theon_selecthandler runs for bothselectandchange.test_every_material2_key_given_with_its_dropdown_spelling_warns_and_the_dropdown_key_wins: all three non-event pairs ondropdown,dropdown_m2anddropdownm2, giving three warnings with the Dropdown values kept.test_a_lone_material2_key_or_dropdown_key_does_not_warn: a regression guard.This replaces
test_dropdown_m2_rejects_a_material2_key_together_with_its_dropdown_spelling, which pinned the raise. Warnings are captured with$VERBOSE = false, so the test does not depend on how the suite is invoked.With the fix, all suites pass:
packages/ruflet_core,ruflet_server,rufletandruflet_rails, each file run on its own.The new
preprocess_propswas also run verbatim on the embedded VM (tools/embedded_vm_harness/build/embedded_mruby --preload). Warnings, wire props and handler dispatch were identical to CRuby.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 comparison includesstderr. The result is{"same" => 183}. No documented example passes both spellings, so none changes or starts warning.This PR and #65 (
on_changehandlers see"change") both editpreprocess_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}.