fix: don't steal focus from search input during focus restoration

When typing in the search bar on a detail page, navigating to search
results would trigger restoreFocusForPage(), which focused the 'last
viewed' card and interrupted typing. Skip focus restoration whenever
the search input is currently the active element.
This commit is contained in:
2026-05-25 13:20:38 +00:00
parent 0330a3023a
commit 1d3d682b60
+4
View File
@@ -412,6 +412,10 @@ function saveFocusForPage(page: string) {
// Restore focus state for a page, or find the last viewed item // Restore focus state for a page, or find the last viewed item
function restoreFocusForPage(page: string) { function restoreFocusForPage(page: string) {
// Don't steal focus from the search input while the user is typing
const active = document.activeElement
if (active?.closest(".header-search")) return
// First try to find the last viewed item and focus it // First try to find the last viewed item and focus it
if (lastViewedItemId.value) { if (lastViewedItemId.value) {
// Use nextTick + timeout to ensure DOM is updated after navigation // Use nextTick + timeout to ensure DOM is updated after navigation