Skip to content

fix: page.update encodes show_*_icon booleans and leading/trailing icon names like construction - #109

Merged
AdamMusa merged 9 commits into
mainfrom
fix/update-icon-props
Nov 20, 2026
Merged

AdamMusa merged 9 commits into
mainfrom
fix/update-icon-props

Conversation

@AdamMusa

@AdamMusa AdamMusa commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Fixes #108

Summary

page.update(control, **props) now encodes the show_*_icon keys and leading:/trailing: the way construction does. Page#icon_prop_key? follows Control#icon_prop_key?:

  • show_* keys are not icons. show_close_icon, show_edit_icon, show_selected_icon and show_trailing_icon are sent as given, so a boolean no longer raises ArgumentError. The engine reads each one with getBool.
  • leading: / trailing: go through a new Page#normalize_icon_slot_value:
    • A known icon name (String, Symbol or IconData) becomes its codepoint. It uses the same Material-then-Cupertino lookup as construction.
    • Every other value is sent exactly as on 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 the show_ guard.
    • New icon_slot_key? and normalize_icon_slot_value, called first in normalize_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.

  1. A show_*_icon update that raised now succeeds. For example, page.update(snack_bar, show_close_icon: false) used to raise ArgumentError: page show_close_icon must use an icon name string, not false. It now sends false.
    • A String value in one of these keys is also sent as given, as construction sends it. Before, a known icon name became a codepoint and anything else raised. The engine's parseBool reads a codepoint and a non-"true" String both as false, so the client renders the same. "true" used to raise and is now read as true.
  2. A leading/trailing icon name that the client dropped now renders as that icon. For example, page.update(list_tile, leading: "info") used to send "info", which buildIconOrWidget discards. It now sends 69374, as Ruflet.list_tile(leading: "info") does. This affects list_tile, cupertino_list_tile, expansion_tile and banner.
    • AppBar, NavigationRail, MenuItemButton, SubmenuButton, Chip and SliverAppBar read leading/trailing with buildWidget, which takes only a control. They now receive the same codepoint that construction sends, and they still draw nothing for it.
  3. The other Page paths that share normalize_value get the same key handling. These are Page#apply_client_update, patch_page, set_view_props, service(...), the page-level page.update(**props) and page.<prop>=. For example, page.apply_client_update(snack_bar.wire_id, {"show_close_icon" => false}) used to raise and now stores false. A client-reported leading: "info" is now stored as 69374 instead of "info". No renderer reports these keys back today: template main and the engine only read them.

Unchanged:

  • Construction, and every other key on page.update.
  • icon: and the other *_icon keys still resolve names and still raise for an unknown name.
  • Keys that only end in leading/trailing, such as bar_leading, are still sent as given.
  • A bare page.update.
  • Every H1 golden.

How it was verified

Numbers below are from 4613ad38 (this branch merged with main ea3f7eb0). ruflet_core, ruflet_server, ruflet_record and the VM ran on earlier merges of this branch whose trees for those packages and ruby_runtime match 4613ad38 exactly.

  • Regression test, page_update_icon_props_test.rb:

    • On main, 4 of the 6 tests fail: two raise ArgumentError and two get raw Strings.
    • The other 2 pin today's pass-through behavior, and also pass on main. They cover leading/trailing values that are not icon names, and icon:/selected_icon: resolving and rejecting unknown names.
    • I planted three mutations, and each one fails the file: removing the 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_tile and list_tile leading/trailing updates 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:

    Package Files Runs Failures Errors Skips
    ruflet_core 204 2064 0 0 1 (needs RUFLET_ENGINE_ROOT; same file on main)
    ruflet 22 707 0 0 0
    ruflet_server 14 56 0 0 0
    ruflet_rails (bundle exec) 17 296 0 0 0
    ruflet_record 7 47 0 0 0
  • H1 goldens: cd packages/ruflet && ruby test/compat/compat.rb --jobs 4 reports "checked 314 goldens" with 0 failing. test/compat_goldens_test.rb: 322 runs, 0 failures.

  • Embedded VM: a fresh arm64 desktop_macos VM built from this tree runs client_state_readers_test, scoped_helper_test, icon_deferral_test, ruflet_gem_test and ruflet_record_gem_test with no failures. In that VM, page.update sends false for show_close_icon: false and 69374 for leading: "info", the same as CRuby.

Not in this PR

page.update still skips a control's own prop renames:

  • Dropdown prefix_icon → leading_icon and select_icon → trailing_icon
  • CupertinoSwitch active_thumb_image/inactive_thumb_image → *_src
  • DropdownOption text → key

Hash- and Array-valued icon props also still differ between construction and update, as on main:

  • Ruflet.switch(thumb_icon: {"selected" => "check"}) sends {"selected" => 66861}, but page.update(switch, thumb_icon: {"selected" => "add"}) raises ArgumentError.
  • 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.

…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
@AdamMusa
AdamMusa merged commit f034e99 into main Nov 20, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant