mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-01 04:55:57 +08:00
chore: add guards to before delete
This commit is contained in:
parent
2886c72833
commit
34e971bc42
1 changed files with 11 additions and 0 deletions
|
|
@ -4,12 +4,23 @@ import * as TestState from "../../test/test-state";
|
|||
import * as TestWords from "../../test/test-words";
|
||||
import { getInputElementValue } from "../input-element";
|
||||
import * as TestUI from "../../test/test-ui";
|
||||
import { isAwaitingNextWord } from "../state";
|
||||
|
||||
export function onBeforeDelete(event: InputEvent): void {
|
||||
if (!TestState.isActive) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (TestState.testRestarting) {
|
||||
return;
|
||||
}
|
||||
if (isAwaitingNextWord()) {
|
||||
return;
|
||||
}
|
||||
if (TestUI.resultCalculating) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { inputValue } = getInputElementValue();
|
||||
const inputIsEmpty = inputValue === "";
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue