Skip to content

fix: route page scroll and drawer methods to the page View - #54

Merged
AdamMusa merged 2 commits into
mainfrom
fix/page-view-methods
Oct 29, 2026
Merged

AdamMusa merged 2 commits into
mainfrom
fix/page-view-methods

Conversation

@AdamMusa

@AdamMusa AdamMusa commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Bug fix approved by the lead (found during Package A / A4, D-10 investigation). Ruby only; no engine change.

Bug

Page#scroll_to, show_drawer, close_drawer, show_end_drawer and close_end_drawer invoked control 1, the Page. On the Flutter engine, the Page's invoke listener (page.dart _invokeMethod) only knows take_screenshot, push_route, get_device_info and set_allowed_device_orientations. For anything else it throws Unknown Page method: …, so these calls failed. The methods are answered by the View:

  • view.dart _invokeMethod handles the drawer methods.
  • The View body's ScrollableControl handles scroll_to.

ruflet_rails already works around this by calling @page.invoke(screen.view, "show_drawer") directly (native_app/navigation.rb).

Design intent

  • The Flutter Page doesn't forward these methods.
  • In Flet, BasePage.scroll_to calls self.__root_view().scroll_to(...) (views[0]), and show_drawer/close_drawer/show_end_drawer/close_end_drawer call self.__top_view() (views[-1]).
  • The existing Ruflet test was already named test_page_scroll_to_invokes_the_root_view_method.

So the fix is on the Ruby side, matching Flet.

Fix

page.rb:

  • invoke accepts :root_view and :top_view. They resolve to the first or last explicit View's wire id (registering the views if they haven't been registered yet), or to the implicit page View id when the app only uses page.add.
  • scroll_to targets :root_view; the four drawer methods target :top_view.
  • The "No drawer defined" check now looks at the drawer of that same top view, so an app with explicit views can open a view's drawer.
  • invoke(:page, …) still targets 1.

Tests

  • New test/page_view_methods_test.rb, 5 runs:
    • With the implicit page, all five methods target the implicit View id, never 1, with the same args.
    • With explicit views, scroll_to → root view and the drawers → top view.
    • Works before page.update has registered the views.
    • The drawer check uses the top view.
    • invoke(:page) still targets 1.
  • Two existing tests asserted the buggy control_id == 1. They now assert the view id: navigation_drawer_compatibility_test, page_compatibility_test#test_page_scroll_to_invokes_the_root_view_method.

verify_pr.sh "" <this tree> with RUBY_PKGS="ruflet_core ruflet ruflet_server ruflet_rails": ruflet_core 146/146 files, 623 runs, ruflet 13/13 (160), ruflet_server 11/11 (40), ruflet_rails 15/15 (278), all PASS. A first run had one timing flake in ruflet/run_command_test.rb#test_handle_reload_command_big_r_requests_full_restart (process-group kill under heavy machine load, unrelated to page.rb); it passed 4/4 times when rerun and on the full rerun. Wire-key audit against engine c9b9d76: NEW 0.

Follow-up: #55 (default page View events) carries a cherry-pick of this commit, because it needs the :root_view invoke target. Merge this PR first; the identical patch then merges cleanly.

Page#scroll_to, show_drawer, close_drawer, show_end_drawer and
close_end_drawer invoked control 1 (the Page). The Flutter Page listener
does not know these methods and answered "Unknown Page method"; the View
owns them. Like Flet, scroll_to now targets the root view and the drawer
methods the top view, which is the implicit page view when the app has
no explicit views. The drawer check follows the same view.
@AdamMusa
AdamMusa merged commit ba6e2e9 into main Oct 29, 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

Development

Successfully merging this pull request may close these issues.

1 participant