mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-30 16:01:14 -04:00
fix(client): prevent client double prefixing i18n paths on quiz exit (#61659)
This commit is contained in:
committed by
GitHub
parent
fa21734931
commit
19af1cdcd2
@@ -1,4 +1,4 @@
|
||||
import { graphql, navigate } from 'gatsby';
|
||||
import { graphql } from 'gatsby';
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import Helmet from 'react-helmet';
|
||||
import { ObserveKeys } from 'react-hotkeys';
|
||||
@@ -128,7 +128,7 @@ const ShowQuiz = ({
|
||||
|
||||
const [showUnanswered, setShowUnanswered] = useState(false);
|
||||
|
||||
const [exitConfirmed, setExitConfirmed] = useState(false);
|
||||
const exitConfirmed = useRef(false);
|
||||
|
||||
const [exitPathname, setExitPathname] = useState(blockHashSlug);
|
||||
|
||||
@@ -247,8 +247,8 @@ const ShowQuiz = ({
|
||||
};
|
||||
|
||||
const handleExitQuizModalBtnClick = () => {
|
||||
setExitConfirmed(true);
|
||||
void navigate(exitPathname || '/learn');
|
||||
exitConfirmed.current = true;
|
||||
void reachNavigate(exitPathname || '/learn');
|
||||
closeExitQuizModal();
|
||||
};
|
||||
|
||||
@@ -267,7 +267,7 @@ const ShowQuiz = ({
|
||||
// - If they don't pass, the Finish Quiz button is disabled, there isn't anything for them to do other than leaving the page
|
||||
// - If they pass, the Submit-and-go button shows up, and campers should be allowed to leave the page
|
||||
// - When they have clicked the exit button on the exit modal
|
||||
if (hasSubmitted || exitConfirmed) {
|
||||
if (hasSubmitted || exitConfirmed.current) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -283,13 +283,7 @@ const ShowQuiz = ({
|
||||
void reachNavigate(`${curLocation.pathname}`);
|
||||
openExitQuizModal();
|
||||
},
|
||||
[
|
||||
curLocation.pathname,
|
||||
hasSubmitted,
|
||||
exitConfirmed,
|
||||
openExitQuizModal,
|
||||
blockHashSlug
|
||||
]
|
||||
[curLocation.pathname, hasSubmitted, openExitQuizModal, blockHashSlug]
|
||||
);
|
||||
|
||||
usePageLeave({
|
||||
|
||||
Reference in New Issue
Block a user