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:
1 parent
0330a3023a
commit
1d3d682b60
1 file changed
+4
@@ -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