Skip to content

Commit d8514c9

Browse files
committed
fix bug input focus
1 parent fbae2a4 commit d8514c9

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/js/components/ui/input/Input.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import type { HTMLAttributes } from 'vue'
2+
import { HTMLAttributes, ref } from 'vue';
33
import { cn } from '@/lib/utils'
44
import { useVModel } from '@vueuse/core'
55
@@ -17,10 +17,18 @@ const modelValue = useVModel(props, 'modelValue', emits, {
1717
passive: true,
1818
defaultValue: props.defaultValue,
1919
})
20+
21+
const inputRef = ref<HTMLInputElement | null>(null);
22+
23+
defineExpose({
24+
input: inputRef,
25+
focus: () => inputRef.value?.focus()
26+
});
2027
</script>
2128

2229
<template>
2330
<input
31+
ref="inputRef"
2432
v-model="modelValue"
2533
data-slot="input"
2634
:class="cn(

0 commit comments

Comments
 (0)