From f1b07376931e7ca7124c5808796d20c86d469760 Mon Sep 17 00:00:00 2001 From: Fraser Tweedale Date: Fri, 13 Oct 2023 11:17:29 +1000 Subject: [PATCH] HMS-2151 fix: remember settings on step-back to token page If the user steps back to the token page, settings they provided in the later pages of wizard are forgotten. Avoid this by updating `onVerify` to return early if it detects that the registered state is already `'completed'`. This avoid overwriting the domain in the wizard state with the "pristine" domain data from the `VerifyRegistry` component. --- src/Routes/WizardPage/WizardPage.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Routes/WizardPage/WizardPage.tsx b/src/Routes/WizardPage/WizardPage.tsx index e834bb9..e069f45 100644 --- a/src/Routes/WizardPage/WizardPage.tsx +++ b/src/Routes/WizardPage/WizardPage.tsx @@ -121,6 +121,12 @@ const WizardPage = () => { }; const onVerify = (value: VerifyState, data?: Domain) => { + if (appContext.wizard.getRegisteredStatus() === 'completed') { + // verify was previously completed (e.g. user stepped the wizard + // back to the token page. Do not overwrite the domain value, + // so that we do not discard any user-specified settings. + return; + } appContext.wizard.setRegisteredStatus(value); if (value === 'completed') { data && appContext.wizard.setDomain(data);