mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-02 21:44:06 +08:00
fix(test): restart not working in long tests (@Leonabcd123) (#7143)
### Description Fixed a bug where you can't use shift + quick restart key to restart long tests. I didn't touch the enter one because it seemed to use a different logic (double tapping shift + enter) and I'm not sure why it does.
This commit is contained in:
parent
032844d023
commit
dfa716a41a
2 changed files with 16 additions and 0 deletions
|
|
@ -10,6 +10,7 @@ import { focusWords } from "../test/test-ui";
|
|||
import * as TestLogic from "../test/test-logic";
|
||||
import { navigate } from "../controllers/route-controller";
|
||||
import { isInputElementFocused } from "../input/input-element";
|
||||
import * as ManualRestart from "../test/manual-restart-tracker";
|
||||
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if (PageTransition.get()) return;
|
||||
|
|
@ -74,6 +75,9 @@ document.addEventListener("keydown", (e) => {
|
|||
) {
|
||||
e.preventDefault();
|
||||
if (ActivePage.get() === "test") {
|
||||
if (e.shiftKey) {
|
||||
ManualRestart.set();
|
||||
}
|
||||
TestLogic.restart();
|
||||
} else {
|
||||
void navigate("");
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import * as Notifications from "../../elements/notifications";
|
|||
import * as KeyConverter from "../../utils/key-converter";
|
||||
import * as ShiftTracker from "../../test/shift-tracker";
|
||||
import * as CompositionState from "../../states/composition";
|
||||
import * as ManualRestart from "../../test/manual-restart-tracker";
|
||||
import { canQuickRestart } from "../../utils/quick-restart";
|
||||
import * as CustomText from "../../test/custom-text";
|
||||
import * as CustomTextState from "../../states/custom-text-name";
|
||||
|
|
@ -28,6 +29,9 @@ export async function handleTab(e: KeyboardEvent, now: number): Promise<void> {
|
|||
if (Config.quickRestart === "tab") {
|
||||
e.preventDefault();
|
||||
if ((TestWords.hasTab && e.shiftKey) || !TestWords.hasTab) {
|
||||
if (e.shiftKey) {
|
||||
ManualRestart.set();
|
||||
}
|
||||
TestLogic.restart();
|
||||
return;
|
||||
}
|
||||
|
|
@ -81,6 +85,9 @@ export async function handleEnter(
|
|||
if (Config.quickRestart === "enter") {
|
||||
e.preventDefault();
|
||||
if ((TestWords.hasNewline && e.shiftKey) || !TestWords.hasNewline) {
|
||||
if (e.shiftKey) {
|
||||
ManualRestart.set();
|
||||
}
|
||||
TestLogic.restart();
|
||||
return;
|
||||
}
|
||||
|
|
@ -206,6 +213,11 @@ export async function onKeydown(event: KeyboardEvent): Promise<void> {
|
|||
|
||||
if (event.key === "Escape" && Config.quickRestart === "esc") {
|
||||
event.preventDefault();
|
||||
|
||||
if (event.shiftKey) {
|
||||
ManualRestart.set();
|
||||
}
|
||||
|
||||
TestLogic.restart();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue