Skip to content

Commit 174dc64

Browse files
committed
fix: prevent navigating with 'enter' if we're waiting to load results
resolves #184
1 parent 312a1fe commit 174dc64

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

app/pages/search.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ const isQueryContinuation = computed(() => {
108108
return previous && current.startsWith(previous)
109109
})
110110
111+
const resultsMatchQuery = computed(() => {
112+
return previousQuery.value === query.value
113+
})
114+
111115
// Show cached results while loading if it's a continuation query
112116
const rawVisibleResults = computed(() => {
113117
if (status.value === 'pending' && isQueryContinuation.value && cachedResults.value) {
@@ -553,7 +557,10 @@ watch(unifiedSelectedIndex, unified => {
553557
watch(
554558
[visibleResults, validatedSuggestions, exactMatchType],
555559
() => {
556-
if (userHasNavigated.value) return
560+
if (userHasNavigated.value) {
561+
unifiedSelectedIndex.value = clampUnifiedIndex(unifiedSelectedIndex.value)
562+
return
563+
}
557564
558565
if (exactMatchType.value === 'package') {
559566
// Find the exact match package index
@@ -649,6 +656,8 @@ function handleResultsKeydown(e: KeyboardEvent) {
649656
}
650657
651658
if (e.key === 'Enter') {
659+
if (!resultsMatchQuery.value) return
660+
652661
const suggIdx = toSuggestionIndex(unifiedSelectedIndex.value)
653662
const pkgIdx = toPackageIndex(unifiedSelectedIndex.value)
654663

0 commit comments

Comments
 (0)