Skip to content

Commit 01114b2

Browse files
committed
fix: handle extra keystrokes
1 parent 6361239 commit 01114b2

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

app/components/AppHeader.vue

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,18 @@ function expandMobileSearch() {
3030
})
3131
}
3232
33-
watch(isOnSearchPage, visible => {
34-
if (!visible) return
33+
watch(
34+
isOnSearchPage,
35+
visible => {
36+
if (!visible) return
3537
36-
searchBoxRef.value?.focus()
37-
nextTick(() => {
3838
searchBoxRef.value?.focus()
39-
})
40-
})
39+
nextTick(() => {
40+
searchBoxRef.value?.focus()
41+
})
42+
},
43+
{ flush: 'sync' },
44+
)
4145
4246
function handleSearchBlur() {
4347
showFullSearch.value = false

app/pages/index.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ async function search() {
1111
path: '/search',
1212
query: query ? { q: query } : undefined,
1313
})
14+
const newQuery = searchQuery.value.trim()
15+
if (newQuery !== query) {
16+
await search()
17+
}
1418
}
1519
1620
const handleInput = isTouchDevice()

0 commit comments

Comments
 (0)