Skip to content

Commit

Permalink
Password form cleared as necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
7emansell committed Dec 19, 2024
1 parent eba37fa commit 5711a27
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/components/MyAccount/Settings/PasswordForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,21 @@ const PasswordForm = ({ patronData, settingsState }: PasswordFormProps) => {

const cancelEditing = () => {
setIsEditing(false)
clearForm()
setEditingField("")
setTimeout(() => {
editingRef.current?.focus()
}, 0)
}

const clearForm = () => {
setFormData({
currentPassword: "",
newPassword: "",
confirmPassword: "",
passwordsMatch: true,
})
}
const validateForm =
formData.currentPassword !== "" &&
formData.newPassword !== "" &&
Expand Down Expand Up @@ -146,6 +155,7 @@ const PasswordForm = ({ patronData, settingsState }: PasswordFormProps) => {
console.error("Error submitting", error)
} finally {
setIsLoading(false)
clearForm()
setEditingField("")
}
}
Expand Down

0 comments on commit 5711a27

Please sign in to comment.