File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { useForm } from '@inertiajs/vue3';
5
5
const modalOpen = defineModel (false , {
6
6
type: Boolean ,
7
7
});
8
+
8
9
const passwordInput = useTemplateRef (' password-input' );
9
10
10
11
const form = useForm ({
@@ -15,7 +16,12 @@ const deleteUser = () => {
15
16
form .delete (route (' profile.destroy' ), {
16
17
preserveScroll: true ,
17
18
onSuccess : () => (modalOpen .value = false ),
18
- onError : () => passwordInput .value .$el .focus (),
19
+ onError : () => {
20
+ const passwordInputElement = passwordInput .value .$el .querySelector (' input' );
21
+ if (passwordInputElement) {
22
+ passwordInputElement .focus ();
23
+ }
24
+ },
19
25
onFinish : () => form .reset (),
20
26
});
21
27
};
@@ -41,6 +47,7 @@ const deleteUser = () => {
41
47
42
48
<div class =" flex flex-col gap-2" >
43
49
<Password
50
+ ref =" password-input"
44
51
id =" password"
45
52
v-model =" form.password"
46
53
:invalid =" Boolean(form.errors?.password)"
Original file line number Diff line number Diff line change @@ -43,11 +43,17 @@ const updatePassword = () => {
43
43
onError : () => {
44
44
if (updatePasswordForm .errors ? .password ) {
45
45
updatePasswordForm .reset (' password' , ' password_confirmation' );
46
- newPasswordInput .value .$el .focus ();
46
+ const newPasswordInputElement = newPasswordInput .value .$el .querySelector (' input' );
47
+ if (newPasswordInputElement) {
48
+ newPasswordInputElement .focus ();
49
+ }
47
50
}
48
51
if (updatePasswordForm .errors ? .current_password ) {
49
52
updatePasswordForm .reset (' current_password' );
50
- currentPasswordInput .value .$el .focus ();
53
+ const currentPasswordInputElement = currentPasswordInput .value .$el .querySelector (' input' );
54
+ if (currentPasswordInputElement) {
55
+ currentPasswordInputElement .focus ();
56
+ }
51
57
}
52
58
},
53
59
});
You can’t perform that action at this time.
0 commit comments