From 46f4c69e5f7e865d88f5a6693c49205df425bfbb Mon Sep 17 00:00:00 2001 From: Miodec Date: Thu, 13 Jul 2023 15:17:22 +0200 Subject: [PATCH] safety check to stop the test if last word is correct but we are still trying to move on to the next word --- frontend/src/ts/controllers/input-controller.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frontend/src/ts/controllers/input-controller.ts b/frontend/src/ts/controllers/input-controller.ts index 226585cd6..994d560d5 100644 --- a/frontend/src/ts/controllers/input-controller.ts +++ b/frontend/src/ts/controllers/input-controller.ts @@ -205,6 +205,11 @@ function handleSpace(): void { Sound.playClick(); } Replay.addReplayEvent("submitCorrectWord"); + if (TestWords.words.currentIndex === TestWords.words.length) { + //submitted last word (checking this in case the test doesnt stop automatically on correct last keypress) + TestLogic.finish(); + return; + } } else { if (!nospace) { if (!Config.playSoundOnError || Config.blindMode) { @@ -1159,6 +1164,8 @@ $("#wordsInput").on("input", (event) => { return; } + console.log("input", inputValue, currTestInput, realInputValue); + if (realInputValue.length === 0 && currTestInput.length === 0) { // fallback for when no Backspace keydown event (mobile) backspaceToPrevious();