diff --git a/frontend/src/ts/test/test-ui.ts b/frontend/src/ts/test/test-ui.ts index 769d8e523e3d..972ece968389 100644 --- a/frontend/src/ts/test/test-ui.ts +++ b/frontend/src/ts/test/test-ui.ts @@ -1286,7 +1286,8 @@ function buildWordLettersHTML( async function loadWordsHistory(): Promise { $("#resultWordsHistory .words").empty(); let wordsHTML = ""; - for (let i = 0; i < TestInput.input.getHistory().length + 2; i++) { + const inputHistoryLength = TestInput.input.getHistory().length; + for (let i = 0; i < inputHistoryLength + 2; i++) { const input = TestInput.input.getHistory(i); const corrected = TestInput.corrected.getHistory(i); const word = TestWords.words.get(i); @@ -1303,8 +1304,19 @@ async function loadWordsHistory(): Promise { throw new Error("empty input word"); } - const errorClass = - Config.mode === "zen" ? "" : input !== word ? "error" : ""; + const isIncorrectWord = input !== word; + const isLastWord = i === inputHistoryLength - 1; + const isTimedTest = + Config.mode === "time" || + (Config.mode === "custom" && CustomText.getLimitMode() === "time") || + (Config.mode === "custom" && CustomText.getLimitValue() === 0); + const isPartiallyCorrect = word.substring(0, input.length) === input; + + const shouldShowError = + Config.mode !== "zen" && + !(isLastWord && isTimedTest && isPartiallyCorrect); + + const errorClass = isIncorrectWord && shouldShowError ? "error" : ""; if (corrected !== undefined && corrected !== "") { const correctedChar = !containsKorean