Force instant scroll on SPA navigation

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-12-09 21:19:12 +00:00
parent d71f7a6615
commit 5f486565fa

View File

@@ -676,13 +676,14 @@ class Spa {
// Scroll Restoration #1: Immediate (after action starts) // Scroll Restoration #1: Immediate (after action starts)
// This occurs synchronously after the action component is created // This occurs synchronously after the action component is created
// May fail if page height is insufficient - that's okay, we'll retry later // May fail if page height is insufficient - that's okay, we'll retry later
// Use behavior: 'instant' to override Bootstrap's scroll-behavior: smooth on :root
if (opts.scroll) { if (opts.scroll) {
console_debug('Spa', 'Restoring scroll position (immediate): ' + opts.scroll.x + ', ' + opts.scroll.y); console_debug('Spa', 'Restoring scroll position (immediate): ' + opts.scroll.x + ', ' + opts.scroll.y);
window.scrollTo(opts.scroll.x, opts.scroll.y); window.scrollTo({ left: opts.scroll.x, top: opts.scroll.y, behavior: 'instant' });
} else if (opts.scroll === undefined) { } else if (opts.scroll === undefined) {
// Default: scroll to top for new navigation (only if scroll not explicitly set) // Default: scroll to top for new navigation (only if scroll not explicitly set)
console_debug('Spa', 'Scrolling to top (new navigation)'); console_debug('Spa', 'Scrolling to top (new navigation)');
window.scrollTo(0, 0); window.scrollTo({ left: 0, top: 0, behavior: 'instant' });
} }
// If opts.scroll === null, don't scroll (let Navigation API or browser handle it) // If opts.scroll === null, don't scroll (let Navigation API or browser handle it)