File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11<script setup lang="ts">
22import { debounce } from ' perfect-debounce'
33
4+ const isMobile = useIsMobile ()
5+
46withDefaults (
57 defineProps <{
68 inputClass? : string
@@ -84,7 +86,7 @@ function handleSearchFocus() {
8486
8587 <input
8688 id =" header-search"
87- autofocus
89+ : autofocus= " !isMobile "
8890 v-model =" searchQuery"
8991 type =" search"
9092 name =" q"
Original file line number Diff line number Diff line change 1+ /**
2+ * Composable for detecting mobile devices using media query.
3+ * Uses the same breakpoint as Tailwind's `md:` (768px).
4+ *
5+ * Returns `false` during SSR to avoid hydration mismatches.
6+ * @public
7+ */
8+ export function useIsMobile ( ) {
9+ return useMediaQuery ( '(max-width: 767px)' )
10+ }
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ const searchQuery = ref('')
66const searchInputRef = useTemplateRef (' searchInputRef' )
77const { focused : isSearchFocused } = useFocus (searchInputRef )
88
9+ const isMobile = useIsMobile ()
10+
911const debouncedNavigate = debounce (() => {
1012 router .push ({
1113 path: ' /search' ,
@@ -76,7 +78,7 @@ defineOgImageComponent('Default')
7678 name =" q"
7779 :placeholder =" $t('search.placeholder')"
7880 v-bind =" noCorrect"
79- autofocus
81+ : autofocus= " !isMobile "
8082 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"
8183 @input =" handleSearch"
8284 />
You can’t perform that action at this time.
0 commit comments