mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-29 02:07:55 +08:00
fix: being able to type in the background while cookie popup is visible
This commit is contained in:
parent
fa5029f905
commit
8897adcec5
4 changed files with 22 additions and 2 deletions
|
|
@ -33,6 +33,7 @@ import * as KeymapEvent from "../observables/keymap-event";
|
|||
import { IgnoredKeys } from "../constants/ignored-keys";
|
||||
import { ModifierKeys } from "../constants/modifier-keys";
|
||||
import { navigate } from "./route-controller";
|
||||
import * as CookiePopup from "../popups/cookie-popup";
|
||||
|
||||
let dontInsertSpace = false;
|
||||
let correctShiftUsed = true;
|
||||
|
|
@ -833,6 +834,10 @@ $(document).on("keydown", async (event) => {
|
|||
|
||||
const popupVisible: boolean = Misc.isAnyPopupVisible();
|
||||
|
||||
const cookiePopupVisible = CookiePopup.isVisible();
|
||||
|
||||
if (cookiePopupVisible) return;
|
||||
|
||||
const allowTyping: boolean =
|
||||
pageTestActive &&
|
||||
!commandLineVisible &&
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import { updateFooterAndVerticalAds } from "../controllers/ad-controller";
|
|||
import * as ModesNotice from "../elements/modes-notice";
|
||||
import * as Keymap from "../elements/keymap";
|
||||
import * as TestConfig from "../test/test-config";
|
||||
import * as CookiePopup from "../popups/cookie-popup";
|
||||
|
||||
export const page = new Page(
|
||||
"test",
|
||||
|
|
@ -35,6 +36,11 @@ export const page = new Page(
|
|||
Keymap.refresh();
|
||||
},
|
||||
async () => {
|
||||
TestUI.focusWords();
|
||||
if (CookiePopup.isVisible()) {
|
||||
TestUI.blurWords();
|
||||
$("#cookiePopupWrapper").trigger("focus");
|
||||
} else {
|
||||
TestUI.focusWords();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -34,9 +34,14 @@ export function check(): void {
|
|||
}
|
||||
}
|
||||
|
||||
export function isVisible(): boolean {
|
||||
return visible;
|
||||
}
|
||||
|
||||
export function show(): void {
|
||||
Skeleton.append(wrapperId);
|
||||
$("#cookiePopupWrapper").removeClass("hidden");
|
||||
visible = true;
|
||||
if (
|
||||
$("#cookiePopupWrapper")[0] === undefined ||
|
||||
$("#cookiePopupWrapper").is(":visible") === false ||
|
||||
|
|
@ -53,7 +58,7 @@ export function show(): void {
|
|||
.stop(true, true)
|
||||
.css("opacity", 0)
|
||||
.removeClass("hidden")
|
||||
.animate({ opacity: 1 }, 125, () => {
|
||||
.animate({ opacity: 1 }, 0, () => {
|
||||
if (
|
||||
$("#cookiePopupWrapper").is(":visible") === false ||
|
||||
$("#cookiePopupWrapper").outerHeight(true) === 0
|
||||
|
|
|
|||
|
|
@ -127,6 +127,10 @@ export function focusWords(): void {
|
|||
}
|
||||
}
|
||||
|
||||
export function blurWords(): void {
|
||||
$("#wordsInput").trigger("blur");
|
||||
}
|
||||
|
||||
export function updateActiveElement(
|
||||
backspace?: boolean,
|
||||
initial = false
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue