From 19af1cdcd29b894d584a5156728fb9b02ae0b96e Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Tue, 23 Sep 2025 11:44:09 +0200 Subject: [PATCH] fix(client): prevent client double prefixing i18n paths on quiz exit (#61659) --- client/src/templates/Challenges/quiz/show.tsx | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/client/src/templates/Challenges/quiz/show.tsx b/client/src/templates/Challenges/quiz/show.tsx index 7f9982b7234..b22705d573c 100644 --- a/client/src/templates/Challenges/quiz/show.tsx +++ b/client/src/templates/Challenges/quiz/show.tsx @@ -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({