Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions resources/js/components/DeleteUser.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { useForm } from '@inertiajs/vue3';
import { ref } from 'vue';
import { useTemplateRef } from 'vue';

// Components
import HeadingSmall from '@/components/HeadingSmall.vue';
Expand All @@ -19,7 +19,7 @@ import {
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';

const passwordInput = ref<HTMLInputElement | null>(null);
const passwordInput = useTemplateRef('passwordInput');

const form = useForm({
password: '',
Expand All @@ -31,7 +31,7 @@ const deleteUser = (e: Event) => {
form.delete(route('profile.destroy'), {
preserveScroll: true,
onSuccess: () => closeModal(),
onError: () => passwordInput.value?.focus(),
onError: () => passwordInput.value?.$el.focus(),
onFinish: () => form.reset(),
});
};
Expand Down
14 changes: 7 additions & 7 deletions resources/js/pages/settings/Password.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import InputError from '@/components/InputError.vue';
import AppLayout from '@/layouts/AppLayout.vue';
import SettingsLayout from '@/layouts/settings/Layout.vue';
import { Head, useForm } from '@inertiajs/vue3';
import { ref } from 'vue';
import { useTemplateRef } from 'vue';

import HeadingSmall from '@/components/HeadingSmall.vue';
import { Button } from '@/components/ui/button';
Expand All @@ -18,8 +18,8 @@ const breadcrumbItems: BreadcrumbItem[] = [
},
];

const passwordInput = ref<HTMLInputElement | null>(null);
const currentPasswordInput = ref<HTMLInputElement | null>(null);
const passwordInput = useTemplateRef('passwordInput');
const currentPasswordInput = useTemplateRef('currentPasswordInput');

const form = useForm({
current_password: '',
Expand All @@ -34,15 +34,15 @@ const updatePassword = () => {
onError: (errors: any) => {
if (errors.password) {
form.reset('password', 'password_confirmation');
if (passwordInput.value instanceof HTMLInputElement) {
passwordInput.value.focus();
if (passwordInput.value?.$el instanceof HTMLInputElement) {
passwordInput.value.$el.focus();
}
}

if (errors.current_password) {
form.reset('current_password');
if (currentPasswordInput.value instanceof HTMLInputElement) {
currentPasswordInput.value.focus();
if (currentPasswordInput.value?.$el instanceof HTMLInputElement) {
currentPasswordInput.value.$el.focus();
}
}
},
Expand Down