Skip to content

Commit 7d6d32d

Browse files
Leonabcd123Miodec
andcommitted
impr(input-history): Change style for incomplete last word in input history (@Leonabcd123) (#7117)
### Description Added a new style named "incomplete" that mirrors the error style, but uses yellow for the color. Words are marked in this style when they don't match the correct word exactly, but share the same prefix. Implements #6690 --------- Co-authored-by: Jack <[email protected]>
1 parent 288301c commit 7d6d32d

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

frontend/src/ts/test/test-ui.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,8 @@ function buildWordLettersHTML(
12861286
async function loadWordsHistory(): Promise<boolean> {
12871287
$("#resultWordsHistory .words").empty();
12881288
let wordsHTML = "";
1289-
for (let i = 0; i < TestInput.input.getHistory().length + 2; i++) {
1289+
const inputHistoryLength = TestInput.input.getHistory().length;
1290+
for (let i = 0; i < inputHistoryLength + 2; i++) {
12901291
const input = TestInput.input.getHistory(i);
12911292
const corrected = TestInput.corrected.getHistory(i);
12921293
const word = TestWords.words.get(i);
@@ -1303,8 +1304,19 @@ async function loadWordsHistory(): Promise<boolean> {
13031304
throw new Error("empty input word");
13041305
}
13051306

1306-
const errorClass =
1307-
Config.mode === "zen" ? "" : input !== word ? "error" : "";
1307+
const isIncorrectWord = input !== word;
1308+
const isLastWord = i === inputHistoryLength - 1;
1309+
const isTimedTest =
1310+
Config.mode === "time" ||
1311+
(Config.mode === "custom" && CustomText.getLimitMode() === "time") ||
1312+
(Config.mode === "custom" && CustomText.getLimitValue() === 0);
1313+
const isPartiallyCorrect = word.substring(0, input.length) === input;
1314+
1315+
const shouldShowError =
1316+
Config.mode !== "zen" &&
1317+
!(isLastWord && isTimedTest && isPartiallyCorrect);
1318+
1319+
const errorClass = isIncorrectWord && shouldShowError ? "error" : "";
13081320

13091321
if (corrected !== undefined && corrected !== "") {
13101322
const correctedChar = !containsKorean

0 commit comments

Comments
 (0)