Skip to content

Commit 378be88

Browse files
committed
More pw input fixes
1 parent ae08bab commit 378be88

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

resources/js/components/DeleteUserModal.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useForm } from '@inertiajs/vue3';
55
const modalOpen = defineModel(false, {
66
type: Boolean,
77
});
8+
89
const passwordInput = useTemplateRef('password-input');
910
1011
const form = useForm({
@@ -15,7 +16,12 @@ const deleteUser = () => {
1516
form.delete(route('profile.destroy'), {
1617
preserveScroll: true,
1718
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+
},
1925
onFinish: () => form.reset(),
2026
});
2127
};
@@ -41,6 +47,7 @@ const deleteUser = () => {
4147

4248
<div class="flex flex-col gap-2">
4349
<Password
50+
ref="password-input"
4451
id="password"
4552
v-model="form.password"
4653
:invalid="Boolean(form.errors?.password)"

resources/js/pages/settings/Password.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,17 @@ const updatePassword = () => {
4343
onError: () => {
4444
if (updatePasswordForm.errors?.password) {
4545
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+
}
4750
}
4851
if (updatePasswordForm.errors?.current_password) {
4952
updatePasswordForm.reset('current_password');
50-
currentPasswordInput.value.$el.focus();
53+
const currentPasswordInputElement = currentPasswordInput.value.$el.querySelector('input');
54+
if (currentPasswordInputElement) {
55+
currentPasswordInputElement.focus();
56+
}
5157
}
5258
},
5359
});

0 commit comments

Comments
 (0)