diff --git a/frontend/src/ts/controllers/input-controller.ts b/frontend/src/ts/controllers/input-controller.ts index 50a7c8bc4249..c90f37acd780 100644 --- a/frontend/src/ts/controllers/input-controller.ts +++ b/frontend/src/ts/controllers/input-controller.ts @@ -1386,9 +1386,18 @@ $("#wordsInput").on("input", (event) => { } } } - if (inputValue !== currTestInput) { + + /* this boolean implies that two input are swipe-typed + consecutively without user inserting space in between */ + const doesInputHaveSpaceBetween = inputValue.trim().includes(" "); + if (inputValue !== currTestInput && !doesInputHaveSpaceBetween) { let diffStart = 0; - while (inputValue[diffStart] === currTestInput[diffStart]) { + // here added undefined check too as the first flag will + // be true even if diffStart overflows the length + while ( + inputValue[diffStart] === currTestInput[diffStart] && + inputValue[diffStart] !== undefined + ) { diffStart++; } @@ -1400,6 +1409,11 @@ $("#wordsInput").on("input", (event) => { // passing realInput to allow for correct Korean character compilation handleChar(inputValue[i] as string, i - iOffset, realInputValue); } + } else { + // simulate space if there is space between input i.e the input is swipe-typed + if (inputValue.trim() !== currTestInput) { + void handleSpace(); + } } setWordsInput(" " + TestInput.input.current);