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
14 changes: 9 additions & 5 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 { nextTick } from 'vue';

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

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

const form = useForm({
password: '',
});
Expand All @@ -31,7 +29,13 @@ const deleteUser = (e: Event) => {
form.delete(route('profile.destroy'), {
preserveScroll: true,
onSuccess: () => closeModal(),
onError: () => passwordInput.value?.focus(),
onError: () => {
nextTick(() => {
const formElement = e.target as HTMLFormElement;
const passwordInput = formElement.password as HTMLInputElement;
passwordInput.focus();
});
},
onFinish: () => form.reset(),
});
};
Expand Down Expand Up @@ -66,7 +70,7 @@ const closeModal = () => {

<div class="grid gap-2">
<Label for="password" class="sr-only">Password</Label>
<Input id="password" type="password" name="password" ref="passwordInput" v-model="form.password" placeholder="Password" />
<Input id="password" type="password" name="password" v-model="form.password" placeholder="Password" />
<InputError :message="form.errors.password" />
</div>

Expand Down
3 changes: 2 additions & 1 deletion resources/js/components/NavUser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { type SharedData, type User } from '@/types';
import { usePage } from '@inertiajs/vue3';
import { ChevronsUpDown } from 'lucide-vue-next';
import UserMenuContent from './UserMenuContent.vue';
import { computed } from 'vue';

const page = usePage<SharedData>();
const user = page.props.auth.user as User;
const user = computed(()=> page.props.auth.user as User);
</script>

<template>
Expand Down