File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 11<script setup lang="ts">
22import { useForm } from ' @inertiajs/vue3' ;
3- import { ref } from ' vue' ;
3+ import { nextTick } from ' vue' ;
44
55// Components
66import HeadingSmall from ' @/components/HeadingSmall.vue' ;
@@ -19,8 +19,6 @@ import {
1919import { Input } from ' @/components/ui/input' ;
2020import { Label } from ' @/components/ui/label' ;
2121
22- const passwordInput = ref <HTMLInputElement | null >(null );
23-
2422const form = useForm ({
2523 password: ' ' ,
2624});
@@ -31,7 +29,13 @@ const deleteUser = (e: Event) => {
3129 form .delete (route (' profile.destroy' ), {
3230 preserveScroll: true ,
3331 onSuccess : () => closeModal (),
34- onError : () => passwordInput .value ?.$el .focus (),
32+ onError : () => {
33+ nextTick (() => {
34+ const formElement = e .target as HTMLFormElement ;
35+ const passwordInput = formElement .password as HTMLInputElement ;
36+ passwordInput .focus ();
37+ });
38+ },
3539 onFinish : () => form .reset (),
3640 });
3741};
@@ -66,7 +70,7 @@ const closeModal = () => {
6670
6771 <div class =" grid gap-2" >
6872 <Label for =" password" class =" sr-only" >Password</Label >
69- <Input id =" password" type =" password" name =" password" ref = " passwordInput " v-model =" form.password" placeholder =" Password" />
73+ <Input id =" password" type =" password" name =" password" v-model =" form.password" placeholder =" Password" />
7074 <InputError :message =" form.errors.password" />
7175 </div >
7276
You can’t perform that action at this time.
0 commit comments