Skip to content

Commit

Permalink
impr: fully prevent typing when a popup is visible
Browse files Browse the repository at this point in the history
closes #5148
closes #5142
  • Loading branch information
Miodec committed Feb 28, 2024
1 parent a0416d3 commit 5147e75
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions frontend/src/ts/controllers/input-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,27 @@ function handleTab(event: JQuery.KeyDownEvent, popupVisible: boolean): void {
}
}

$("#wordsInput").on("keydown", (event) => {
const pageTestActive: boolean = ActivePage.get() === "test";
const commandLineVisible = Misc.isPopupVisible("commandLineWrapper");
const leaderboardsVisible = Misc.isPopupVisible("leaderboardsWrapper");
const popupVisible: boolean = Misc.isAnyPopupVisible();
const cookiePopupVisible = CookiePopup.isVisible();

const allowTyping: boolean =
pageTestActive &&
!commandLineVisible &&
!leaderboardsVisible &&
!popupVisible &&
!TestUI.resultVisible &&
!cookiePopupVisible &&
event.key !== "Enter";

if (!allowTyping) {
event.preventDefault();
}
});

let lastBailoutAttempt = -1;

$(document).on("keydown", async (event) => {
Expand Down

0 comments on commit 5147e75

Please sign in to comment.