Add scroll restoration on browser refresh for SPA pages

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2026-01-28 20:27:28 +00:00
parent 90efeab7ea
commit d5572e6081
2 changed files with 81 additions and 10 deletions

View File

@@ -573,6 +573,10 @@ class Spa {
// Errors from previous page's pending requests should be ignored for 10 seconds
Spa._navigation_timestamp = Date.now();
// Reset any pending scroll restoration from previous navigation
// (Browser refresh scroll is handled separately by Rsx._restore_scroll_on_refresh)
Rsx.reset_pending_scroll();
try {
const opts = {
history: options.history || 'auto',
@@ -938,6 +942,12 @@ class Spa {
if (is_last) {
// This is the action - set reference but don't wait
Spa._action = component;
// After action is fully ready (on_load + on_ready complete), retry scroll restoration
// This handles cases where on_load fetches data that increases page height
component.ready().then(() => {
Rsx.try_restore_scroll();
});
} else {
// This is a layout
// Wait for render to complete (not full ready - we don't need child data to load)