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:
@@ -412,6 +412,10 @@ function saveFocusForPage(page: string) {
|
||||
|
||||
// Restore focus state for a page, or find the last viewed item
|
||||
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
|
||||
if (lastViewedItemId.value) {
|
||||
// Use nextTick + timeout to ensure DOM is updated after navigation
|
||||
|
||||
Reference in New Issue
Block a user