Skip to content

Router route changes can retain the previous Scroll offset on Web #174

Description

@zcourts

Summary

When two Web routes render through the same shell position and each route contains a scrollable screen, navigating from a deeply scrolled first route can cause the second route to start at the old scroll offset rather than at its top.

In the observed case, the new route's leading content was outside the viewport. Resizing the browser caused another layout/render and made the expected initial content visible.

Representative reproduction

Build a small Fission Web application with:

  • a Router;
  • route A containing a tall Scroll with enough rows to scroll several screens;
  • route B containing a different screen in the same routed shell position; and
  • a button near the bottom of route A that navigates to route B.

Steps:

  1. Open route A.
  2. Scroll near the bottom.
  3. Activate the button that navigates to route B.
  4. Observe the initial vertical position of route B.
  5. Resize the viewport and compare the result.

No explicit shared WidgetId or application-owned scroll state is used.

Expected behavior

A newly entered route should start at its own default scroll position unless the application explicitly supplies a stable scroll identity/state that requests restoration.

Retained widget optimization must not make unrelated routed screens accidentally share scroll state.

Actual behavior

The routed replacement can inherit the prior screen's scroll offset. Important leading content may appear missing until another viewport/layout event occurs.

Suggested implementation direction

Include route identity in retained subtree identity, or reset Scroll state when the routed child identity changes. Explicit application-owned restoration should remain possible.

Suggested regression test

Navigate from the bottom of a tall route to a distinct route rendered at the same tree position and assert the new route's Scroll offset is zero before any resize event.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions