Skip to content

Commit 0d9a1d9

Browse files
committed
fix: backspace always playing error sound
1 parent 6826610 commit 0d9a1d9

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

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

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,15 +1637,22 @@ export function getActiveWordTopAfterAppend(data: string): number {
16371637
}
16381638

16391639
// this means input, delete or composition
1640-
function afterAnyTestInput(correctInput: boolean | null): void {
1641-
if (
1642-
correctInput === true ||
1643-
Config.playSoundOnError === "off" ||
1644-
Config.blindMode
1645-
) {
1640+
function afterAnyTestInput(
1641+
type: "textInput" | "delete" | "compositionUpdate",
1642+
correctInput: boolean | null
1643+
): void {
1644+
if (type === "textInput") {
1645+
if (
1646+
correctInput === true ||
1647+
Config.playSoundOnError === "off" ||
1648+
Config.blindMode
1649+
) {
1650+
void SoundController.playClick();
1651+
} else {
1652+
void SoundController.playError();
1653+
}
1654+
} else if (type === "delete") {
16461655
void SoundController.playClick();
1647-
} else {
1648-
void SoundController.playError();
16491656
}
16501657

16511658
const acc: number = Numbers.roundTo2(TestStats.calculateAccuracy());
@@ -1684,18 +1691,18 @@ export function afterTestTextInput(
16841691
}
16851692
}
16861693

1687-
afterAnyTestInput(correct);
1694+
afterAnyTestInput("textInput", correct);
16881695
}
16891696

16901697
export function afterTestCompositionUpdate(): void {
16911698
void updateActiveWordLetters();
16921699
// correct needs to be true to get the normal click sound
1693-
afterAnyTestInput(true);
1700+
afterAnyTestInput("compositionUpdate", true);
16941701
}
16951702

16961703
export function afterTestDelete(): void {
16971704
void updateActiveWordLetters();
1698-
afterAnyTestInput(null);
1705+
afterAnyTestInput("delete", null);
16991706
}
17001707

17011708
export function beforeTestWordChange(

0 commit comments

Comments
 (0)