From 4e46f6bc9fa428a27afa398b05982278855e239f Mon Sep 17 00:00:00 2001 From: Miodec Date: Tue, 11 Jun 2024 14:25:28 +0200 Subject: [PATCH] fix(typig test): blind mode not highlighting missed characters as correct (turns out that "old unused code" was actually quite important) --- frontend/src/ts/controllers/input-controller.ts | 8 +++++++- frontend/src/ts/test/test-ui.ts | 9 +++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/frontend/src/ts/controllers/input-controller.ts b/frontend/src/ts/controllers/input-controller.ts index ec6f6e60f..859b54f54 100644 --- a/frontend/src/ts/controllers/input-controller.ts +++ b/frontend/src/ts/controllers/input-controller.ts @@ -267,8 +267,14 @@ async function handleSpace(): Promise { return; } PaceCaret.handleSpace(false, currentWord); + if (Config.blindMode) { + if (Config.highlightMode !== "off") { + TestUI.highlightAllLettersAsCorrect(TestUI.currentWordElementIndex); + } + } else { + TestUI.highlightBadWord(TestUI.currentWordElementIndex); + } TestInput.input.pushHistory(); - TestUI.highlightBadWord(TestUI.currentWordElementIndex, !Config.blindMode); TestWords.words.increaseCurrentIndex(); Funbox.toggleScript(TestWords.words.getCurrent()); TestInput.incrementKeypressCount(); diff --git a/frontend/src/ts/test/test-ui.ts b/frontend/src/ts/test/test-ui.ts index 5bd4c8f6c..94512e7f9 100644 --- a/frontend/src/ts/test/test-ui.ts +++ b/frontend/src/ts/test/test-ui.ts @@ -1408,11 +1408,16 @@ export async function applyBurstHeatmap(): Promise { } } -export function highlightBadWord(index: number, showError: boolean): void { - if (!showError) return; +export function highlightBadWord(index: number): void { $($("#words .word")[index] as HTMLElement).addClass("error"); } +export function highlightAllLettersAsCorrect(wordIndex: number): void { + $($("#words .word")[wordIndex] as HTMLElement) + .find("letter") + .addClass("correct"); +} + export function highlightMode(mode?: SharedTypes.Config.HighlightMode): void { const existing = $("#words")