Skip to content

Commit d9cdf34

Browse files
committed
fix: prevent suggestion dropdown from closing when clicking scrollbar
1 parent dd3c186 commit d9cdf34

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

app/components/Compare/PackageSelector.vue

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -183,18 +183,12 @@ watch(highlightedIndex, index => {
183183
}
184184
})
185185
186-
const { start, stop } = useTimeoutFn(() => {
187-
isInputFocused.value = false
188-
}, 200)
189-
190-
function handleBlur() {
191-
start()
192-
}
186+
const containerRef = useTemplateRef('containerRef')
193187
194-
function handleFocus() {
195-
stop()
196-
isInputFocused.value = true
197-
}
188+
onClickOutside(containerRef, () => {
189+
isInputFocused.value = false
190+
highlightedIndex.value = -1
191+
})
198192
</script>
199193

200194
<template>
@@ -226,7 +220,7 @@ function handleFocus() {
226220
</div>
227221

228222
<!-- Add package input -->
229-
<div v-if="packages.length < maxPackages" class="relative">
223+
<div v-if="packages.length < maxPackages" ref="containerRef" class="relative">
230224
<div class="relative group flex items-center">
231225
<label for="package-search" class="sr-only">
232226
{{ $t('compare.selector.search_label') }}
@@ -249,8 +243,8 @@ function handleFocus() {
249243
size="medium"
250244
class="w-full min-w-25 ps-7"
251245
aria-autocomplete="list"
252-
@focus="handleFocus"
253-
@blur="handleBlur"
246+
ref="inputRef"
247+
@focus="isInputFocused = true"
254248
@keydown="handleKeydown"
255249
/>
256250
</div>

0 commit comments

Comments
 (0)