Skip to content

Commit 215db77

Browse files
refactor(home): remove redirect while typing
1 parent 94a7441 commit 215db77

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

app/pages/index.vue

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
<script setup lang="ts">
2-
import { debounce } from 'perfect-debounce'
3-
42
const router = useRouter()
53
const searchQuery = ref('')
64
const searchInputRef = useTemplateRef('searchInputRef')
75
const { focused: isSearchFocused } = useFocus(searchInputRef)
86
9-
const debouncedNavigate = debounce(() => {
7+
function handleSearch() {
108
router.push({
11-
path: '/search',
12-
query: searchQuery.value.trim() ? { q: searchQuery.value.trim() } : undefined,
9+
name: 'search',
10+
query: {
11+
q: searchQuery.value.trim(),
12+
},
1313
})
14-
}, 250)
15-
16-
function handleSearch() {
17-
// If input is empty, navigate immediately (no need to debounce)
18-
return searchQuery.value.trim() ? debouncedNavigate() : router.push('/search')
1914
}
2015
2116
useSeoMeta({
@@ -78,7 +73,6 @@ defineOgImageComponent('Default')
7873
v-bind="noCorrect"
7974
autofocus
8075
class="w-full bg-bg-subtle border border-border rounded-lg ps-8 pe-24 py-4 font-mono text-base text-fg placeholder:text-fg-subtle transition-border-color duration-300 focus:border-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50"
81-
@input="handleSearch"
8276
/>
8377

8478
<button

0 commit comments

Comments
 (0)