From 8b03b2e22f199f7a6e2f1173c7329cda3d94f941 Mon Sep 17 00:00:00 2001 From: ren <18050944+renintw@users.noreply.github.com> Date: Wed, 7 Jun 2023 06:24:56 +0800 Subject: [PATCH] Can't go back if there's checkbox_confirmation_required error --- settings/src/script.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/settings/src/script.js b/settings/src/script.js index fcfccb44..af318585 100644 --- a/settings/src/script.js +++ b/settings/src/script.js @@ -121,15 +121,21 @@ function Main( { userId } ) { */ const navigateToScreen = useCallback( ( { currentScreen, nextScreen } ) => { - // If there's already another error, do not overwrite it with the error below. - // Because usually, if there are other errors, it means there's a problem with the backup code generation. - // When this happens, users shouldn't need to confirm the checkbox to leave the current screen. - if ( 'backup-codes' === currentScreen && ! error && ! hasBackupCodesPrinted ) { - setError( { - code: 'checkbox_confirmation_required', - message: 'Confirmation is required. Please check the checkbox to continue.', - } ); - return; + if ( 'backup-codes' === currentScreen ) { + // If there's already another error, do not overwrite it with the error below. + // Because usually, if there are other errors, it means there's a problem with the backup code generation. + // When this happens, users shouldn't need to confirm the checkbox to leave the current screen. + if ( ! error && ! hasBackupCodesPrinted ) { + setError( { + code: 'checkbox_confirmation_required', + message: 'Confirmation is required. Please check the checkbox to continue.', + } ); + return; + } + + if ( error.code === 'checkbox_confirmation_required' ) { + return; + } } // Reset to initial after navigating away from a page.