From 99ac05d819810f490fbf981334c45390e2d8e5ee Mon Sep 17 00:00:00 2001 From: Michal Zielenkiewicz Date: Thu, 21 Sep 2023 10:40:58 +0200 Subject: [PATCH] Reset form errors on unmount --- .../Toolbar/Features/Profile/UpdatePassword.tsx | 8 ++++++++ src/app/state/persist/index.ts | 3 +++ 2 files changed, 11 insertions(+) diff --git a/src/app/components/Toolbar/Features/Profile/UpdatePassword.tsx b/src/app/components/Toolbar/Features/Profile/UpdatePassword.tsx index 6bc2268661..d4bbfb3021 100644 --- a/src/app/components/Toolbar/Features/Profile/UpdatePassword.tsx +++ b/src/app/components/Toolbar/Features/Profile/UpdatePassword.tsx @@ -1,3 +1,4 @@ +import { useEffect } from 'react' import { useDispatch, useSelector } from 'react-redux' import { useTranslation } from 'react-i18next' import { Box } from 'grommet/es6/components/Box' @@ -30,6 +31,13 @@ export const UpdatePassword = () => { ) } + useEffect(() => { + return () => { + console.log('clear') + dispatch(persistActions.resetWrongPassword()) + } + }, [dispatch]) + return ( onSubmit={onSubmit} {...preventSavingInputsToUserData}> diff --git a/src/app/state/persist/index.ts b/src/app/state/persist/index.ts index c7c9986dd9..51098bf2c1 100644 --- a/src/app/state/persist/index.ts +++ b/src/app/state/persist/index.ts @@ -85,6 +85,9 @@ const persistSlice = createSlice({ deleteProfileAsync(state) { state.loading = true }, + resetWrongPassword(state) { + state.enteredWrongPassword = false + }, updatePassword(state, action: PayloadAction) { return },