Skip to content

Commit a5307c1

Browse files
committed
feat: focus URL input on app start
Closes #341
1 parent c168d83 commit a5307c1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/components/TheHeader.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
class="input join-item w-full"
99
:placeholder="inputPlaceholder"
1010
type="text"
11+
ref="input"
1112
/>
1213
<button
1314
class="btn btn-primary join-item"
@@ -28,7 +29,7 @@
2829
2930
import { CogIcon } from '@heroicons/vue/24/outline';
3031
import { useMediaStore } from '../stores/media/media';
31-
import { ref, computed } from 'vue';
32+
import { ref, computed, onMounted } from 'vue';
3233
import { useClipboard } from '../composables/useClipboard';
3334
import { useRouter } from 'vue-router';
3435
import { useI18n } from 'vue-i18n';
@@ -46,6 +47,8 @@ const { content: clipboardContent } = useClipboard({
4647
doPolling,
4748
});
4849
50+
const input = ref<HTMLInputElement | null>(null);
51+
4952
const inputPlaceholder = computed(() => {
5053
const defaultPlaceholder = t('layout.header.placeholder');
5154
if (clipboardHasValidUrl.value) {
@@ -79,4 +82,8 @@ const submitUrl = () => {
7982
void router.push('/');
8083
};
8184
85+
onMounted(() => {
86+
input.value?.focus();
87+
});
88+
8289
</script>

0 commit comments

Comments
 (0)