Skip to content

Commit f053780

Browse files
authored
Merge pull request #39 from connorabbas/develop
Password input fixes
2 parents 1977700 + 3cc1ad5 commit f053780

File tree

7 files changed

+38
-21
lines changed

7 files changed

+38
-21
lines changed

.github/workflows/eslint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ jobs:
2222
run: npm ci
2323

2424
- name: Run ESLint
25-
run: npm run lint
25+
run: npx eslint .

src/components/DeleteUserModal.vue

+10-8
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@ const deleteAccount = () => {
3434
setFlashMessage('success', 'Your account has been deleted.');
3535
});
3636
},
37-
onError: () => passwordInput.value.$el.focus(),
37+
onError: () => {
38+
console.error('error');
39+
const passwordInputElement = passwordInput.value.$el.querySelector('input');
40+
if (passwordInputElement) {
41+
passwordInputElement.focus();
42+
}
43+
},
3844
onFinish: () => resetFormFields(),
3945
});
4046
};
41-
42-
function focusPasswordInput() {
43-
passwordInput.value.$el.focus();
44-
}
4547
</script>
4648

4749
<template>
@@ -53,7 +55,6 @@ function focusPasswordInput() {
5355
:draggable="false"
5456
dismissableMask
5557
modal
56-
@show="focusPasswordInput"
5758
>
5859
<div class="mb-6">
5960
<p class="m-0 text-muted-color">
@@ -64,14 +65,15 @@ function focusPasswordInput() {
6465
</div>
6566

6667
<div class="flex flex-col gap-2">
67-
<InputText
68+
<Password
6869
id="password"
6970
ref="password-input"
7071
v-model="formData.password"
7172
:invalid="Boolean(validationErrors?.password)"
72-
type="password"
7373
placeholder="Password"
7474
autocomplete="current-password"
75+
:feedback="false"
76+
toggleMask
7577
autofocus
7678
required
7779
fluid

src/composables/useAxiosForm.js

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export function useAxiosForm(initialData = {}) {
2525
showProgress = false,
2626
onBefore = () => {},
2727
onSuccess = () => {},
28+
onError = () => {},
2829
onFinish = () => {},
2930
...restOptions
3031
} = options;
@@ -47,6 +48,7 @@ export function useAxiosForm(initialData = {}) {
4748

4849
return response;
4950
} catch (error) {
51+
onError(error);
5052
handleAxiosError(error);
5153
} finally {
5254
onFinish();

src/views/auth/Login.vue

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ onMounted(() => {
9090
id="password"
9191
v-model="formData.password"
9292
:invalid="Boolean(validationErrors?.password)"
93+
:feedback="false"
9394
autocomplete="current-password"
9495
toggleMask
9596
required

src/views/auth/Register.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,13 @@ onMounted(() => {
9292

9393
<div class="flex flex-col gap-2">
9494
<label for="password_confirmation">Confirm Password</label>
95-
<InputText
95+
<Password
9696
id="password_confirmation"
9797
v-model="formData.password_confirmation"
9898
:invalid="Boolean(validationErrors?.password_confirmation)"
99-
type="password"
99+
:feedback="false"
100100
autocomplete="new-password"
101+
toggleMask
101102
required
102103
fluid
103104
/>

src/views/auth/ResetPassword.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,13 @@ onMounted(() => {
9090
9191
<div class="flex flex-col gap-2">
9292
<label for="password_confirmation">Confirm New Password</label>
93-
<InputText
93+
<Password
9494
id="password_confirmation"
9595
v-model="formData.password_confirmation"
9696
:invalid="Boolean(validationErrors?.password_confirmation)"
97-
type="password"
97+
:feedback="false"
9898
autocomplete="new-password"
99+
toggleMask
99100
required
100101
fluid
101102
/>

src/views/settings/Password.vue

+18-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup>
2-
import { useTemplateRef } from 'vue';
2+
import { useTemplateRef, nextTick } from 'vue';
33
import { useToast } from 'primevue/usetoast';
44
import { useAuthStore } from '@/stores/auth';
55
import { useAxiosForm } from '@/composables/useAxiosForm';
@@ -38,14 +38,22 @@ const submit = () => {
3838
resetFormFields();
3939
authStore.fetchUser();
4040
},
41-
onError: () => {
41+
onError: async () => {
42+
await nextTick();
4243
if (validationErrors.value?.password) {
4344
resetFormFields('password', 'password_confirmation');
44-
newPasswordInput.value.$el.focus();
45+
const newPasswordInputElement = newPasswordInput.value.$el.querySelector('input');
46+
if (newPasswordInputElement) {
47+
newPasswordInputElement.focus();
48+
}
4549
}
4650
if (validationErrors.value?.current_password) {
4751
resetFormFields('current_password');
48-
currentPasswordInput.value.$el.focus();
52+
const currentPasswordInputElement = currentPasswordInput.value.$el.querySelector('input');
53+
console.log(currentPasswordInput.value.$el);
54+
if (currentPasswordInputElement) {
55+
currentPasswordInputElement.focus();
56+
}
4957
}
5058
},
5159
});
@@ -72,13 +80,14 @@ const submit = () => {
7280
>
7381
<div class="flex flex-col gap-2">
7482
<label for="current_password">Current Password</label>
75-
<InputText
83+
<Password
7684
id="current_password"
7785
ref="current-password-input"
7886
v-model="formData.current_password"
7987
:invalid="Boolean(validationErrors?.current_password)"
80-
type="password"
88+
:feedback="false"
8189
autocomplete="current-password"
90+
toggleMask
8291
required
8392
fluid
8493
/>
@@ -102,12 +111,13 @@ const submit = () => {
102111
103112
<div class="flex flex-col gap-2">
104113
<label for="password_confirmation">Confirm Password</label>
105-
<InputText
114+
<Password
106115
id="password_confirmation"
107116
v-model="formData.password_confirmation"
108117
:invalid="Boolean(validationErrors?.password_confirmation)"
109-
type="password"
118+
:feedback="false"
110119
autocomplete="confirm-password"
120+
toggleMask
111121
required
112122
fluid
113123
/>

0 commit comments

Comments
 (0)