Skip to content

dialog fixes #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 21, 2024
Merged
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
16 changes: 6 additions & 10 deletions resources/js/Pages/Profile/Partials/DeleteUserForm.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import { ref, useTemplateRef, watch, nextTick } from 'vue';
import { ref, useTemplateRef } from 'vue';
import { useForm } from '@inertiajs/vue3';
import Dialog from 'primevue/dialog';
import InputError from '@/Components/InputError.vue';
Expand All @@ -20,25 +20,21 @@ const deleteUser = () => {
});
};

watch(modalOpen, (newModalOpen) => {
if (newModalOpen) {
nextTick(() => {
passwordInput.value.$el.focus();
});
} else {
form.clearErrors();
}
});
function focusPasswordInput() {
passwordInput.value.$el.focus();
}
</script>

<template>
<section class="space-y-6">
<Dialog
:draggable="false"
position="center"
v-model:visible="modalOpen"
modal
header="Are you sure you want to delete your account?"
:style="{ width: '40rem' }"
@show="focusPasswordInput"
>
<div class="mb-6">
<p class="m-0 text-muted-color">
Expand Down
6 changes: 3 additions & 3 deletions resources/js/Pages/Profile/Partials/UpdatePasswordForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useToast } from 'primevue/usetoast';
import InputError from '@/Components/InputError.vue';

const currentPasswordInput = useTemplateRef('current-password-input');
const passwordInput = useTemplateRef('password-input');
const newPasswordInput = useTemplateRef('new-password-input');

const toast = useToast();
const form = useForm({
Expand All @@ -32,7 +32,7 @@ const updatePassword = () => {
onError: () => {
if (form.errors?.password) {
form.reset('password', 'password_confirmation');
passwordInput.value.$el.focus();
newPasswordInput.value.$el.focus();
}
if (form.errors?.current_password) {
form.reset('current_password');
Expand Down Expand Up @@ -79,7 +79,7 @@ const updatePassword = () => {
<InputText
required
id="password"
ref="password-input"
ref="new-password-input"
type="password"
v-model="form.password"
class="w-full"
Expand Down