diff --git a/frontend/src/ts/controllers/input-controller.ts b/frontend/src/ts/controllers/input-controller.ts index 37ed38475..1c118a1dc 100644 --- a/frontend/src/ts/controllers/input-controller.ts +++ b/frontend/src/ts/controllers/input-controller.ts @@ -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 && diff --git a/frontend/src/ts/pages/test.ts b/frontend/src/ts/pages/test.ts index 6b25fe653..a66391e4f 100644 --- a/frontend/src/ts/pages/test.ts +++ b/frontend/src/ts/pages/test.ts @@ -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(); + } } ); diff --git a/frontend/src/ts/popups/cookie-popup.ts b/frontend/src/ts/popups/cookie-popup.ts index 0115c365f..936d6779c 100644 --- a/frontend/src/ts/popups/cookie-popup.ts +++ b/frontend/src/ts/popups/cookie-popup.ts @@ -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 diff --git a/frontend/src/ts/test/test-ui.ts b/frontend/src/ts/test/test-ui.ts index eecee9234..0d7106170 100644 --- a/frontend/src/ts/test/test-ui.ts +++ b/frontend/src/ts/test/test-ui.ts @@ -127,6 +127,10 @@ export function focusWords(): void { } } +export function blurWords(): void { + $("#wordsInput").trigger("blur"); +} + export function updateActiveElement( backspace?: boolean, initial = false