Skip to content

Commit

Permalink
Can't go back if there's checkbox_confirmation_required error
Browse files Browse the repository at this point in the history
  • Loading branch information
renintw committed Jun 6, 2023
1 parent bf4f08f commit cb9296b
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions settings/src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit cb9296b

Please sign in to comment.