Repository navigation
fix: page.update encodes show_*_icon booleans and leading/trailing icon names like construction - #109
Merged
Merged
Conversation
…truction Page#icon_prop_key? treated every "*_icon" key as an icon name, so a boolean show_close_icon, show_edit_icon, show_selected_icon or show_trailing_icon raised ArgumentError on page.update. It also left leading/trailing out, so an icon name there was sent as a String that the renderer's buildIconOrWidget drops. Page now follows Control#icon_prop_key?: show_* keys are not icons, and a known icon name in leading/trailing becomes its codepoint. Any other leading/trailing value (control, Integer, nil, unknown name) is sent as before, so nothing that worked starts raising. Fixes #108
This was referenced Nov 20, 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 #108
Summary
page.update(control, **props)now encodes theshow_*_iconkeys andleading:/trailing:the way construction does.Page#icon_prop_key?followsControl#icon_prop_key?:show_*keys are not icons.show_close_icon,show_edit_icon,show_selected_iconandshow_trailing_iconare sent as given, so a boolean no longer raisesArgumentError. The engine reads each one withgetBool.leading:/trailing:go through a newPage#normalize_icon_slot_value:IconData) becomes its codepoint. It uses the same Material-then-Cupertino lookup as construction.main, so nothing that worked starts raising. That covers a control, an Integer codepoint,nil, an empty string and an unknown name. Construction rejects some of these values; update keeps accepting them.Changes
packages/ruflet_core/lib/ruflet_ui/ruflet/page.rb:icon_prop_key?gets theshow_guard.icon_slot_key?andnormalize_icon_slot_value, called first innormalize_value.packages/ruflet_core/test/page_update_icon_props_test.rb: 6 new tests.Behavior changes
All are bug fixes. None requires an app code change.
show_*_iconupdate that raised now succeeds. For example,page.update(snack_bar, show_close_icon: false)used to raiseArgumentError: page show_close_icon must use an icon name string, not false. It now sendsfalse.parseBoolreads a codepoint and a non-"true"String both asfalse, so the client renders the same."true"used to raise and is now read astrue.leading/trailingicon name that the client dropped now renders as that icon. For example,page.update(list_tile, leading: "info")used to send"info", whichbuildIconOrWidgetdiscards. It now sends 69374, asRuflet.list_tile(leading: "info")does. This affectslist_tile,cupertino_list_tile,expansion_tileandbanner.leading/trailingwithbuildWidget, which takes only a control. They now receive the same codepoint that construction sends, and they still draw nothing for it.Pagepaths that sharenormalize_valueget the same key handling. These arePage#apply_client_update,patch_page,set_view_props,service(...), the page-levelpage.update(**props)andpage.<prop>=. For example,page.apply_client_update(snack_bar.wire_id, {"show_close_icon" => false})used to raise and now storesfalse. A client-reportedleading: "info"is now stored as 69374 instead of"info". No renderer reports these keys back today: templatemainand the engine only read them.Unchanged:
page.update.icon:and the other*_iconkeys still resolve names and still raise for an unknown name.leading/trailing, such asbar_leading, are still sent as given.page.update.How it was verified
Numbers below are from
4613ad38(this branch merged withmainea3f7eb0).ruflet_core,ruflet_server,ruflet_recordand the VM ran on earlier merges of this branch whose trees for those packages andruby_runtimematch4613ad38exactly.Regression test,
page_update_icon_props_test.rb:main, 4 of the 6 tests fail: two raiseArgumentErrorand two get raw Strings.main. They cover leading/trailing values that are not icon names, andicon:/selected_icon:resolving and rejecting unknown names.show_guard, removing the leading/trailing branch, and making the leading/trailing branch strict, so that it raises for an unknown name.Probes from the bug report: all four
show_*updates send their booleans.expansion_tileandlist_tileleading/trailingupdates send codepoints. In the construction-vs-update sweep, divergences drop from 18 to 5. The 5 that remain are prop renames, listed under "Not in this PR".Suites, one process per test file:
ruflet_coreRUFLET_ENGINE_ROOT; same file on main)rufletruflet_serverruflet_rails(bundle exec)ruflet_recordH1 goldens:
cd packages/ruflet && ruby test/compat/compat.rb --jobs 4reports "checked 314 goldens" with 0 failing.test/compat_goldens_test.rb: 322 runs, 0 failures.Embedded VM: a fresh arm64
desktop_macosVM built from this tree runsclient_state_readers_test,scoped_helper_test,icon_deferral_test,ruflet_gem_testandruflet_record_gem_testwith no failures. In that VM,page.updatesendsfalseforshow_close_icon: falseand 69374 forleading: "info", the same as CRuby.Not in this PR
page.updatestill skips a control's own prop renames:prefix_icon→leading_iconandselect_icon→trailing_iconactive_thumb_image/inactive_thumb_image→*_srctext→keyHash- and Array-valued icon props also still differ between construction and update, as on
main:Ruflet.switch(thumb_icon: {"selected" => "check"})sends{"selected" => 66861}, butpage.update(switch, thumb_icon: {"selected" => "add"})raisesArgumentError.leading: ["info"]becomes[69374]at construction and stays["info"]on update.Applying either on update would change what is sent for an existing call, so each is left for a separate change.