We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 7348408 + 3b46905 commit 700550fCopy full SHA for 700550f
components/NavBar.vue
@@ -10,9 +10,18 @@ const searchQuery = useSearchQuery();
10
11
const searchInput = ref<HTMLInputElement | null>(null);
12
13
-onMounted(() => {
14
- searchInput.value?.focus(); // Focus the search input when the component is mounted
15
-});
+watch(
+ () => route.path,
+ (newPath) => {
16
+ if (newPath === "/") {
17
+ // focus the search input field when navigating to the main page
18
+ nextTick(() => {
19
+ searchInput.value?.focus();
20
+ });
21
+ }
22
+ },
23
+ { immediate: true }
24
+);
25
26
watch(searchQuery, () => {
27
// if the search query is empty and the search query in the URL is empty,
0 commit comments