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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user