diff --git a/frontend/src/ts/ui.ts b/frontend/src/ts/ui.ts index 28cd2a56b..a41c06d8c 100644 --- a/frontend/src/ts/ui.ts +++ b/frontend/src/ts/ui.ts @@ -6,6 +6,7 @@ import * as TestActive from "./states/test-active"; import * as ConfigEvent from "./observables/config-event"; import { debounce, throttle } from "throttle-debounce"; import * as TestUI from "./test/test-ui"; +import { get as getActivePage } from "./states/active-page"; export function updateKeytips(): void { if (Config.swapEscAndTab) { @@ -77,9 +78,13 @@ window.addEventListener("beforeunload", (event) => { } }); -const debouncedCaretUpdate = debounce(250, async () => { +const debouncedEvent = debounce(250, async () => { Caret.updatePosition(); - if (Config.tapeMode !== "off") { + if ( + Config.tapeMode !== "off" && + getActivePage() === "test" && + !TestUI.resultVisible + ) { TestUI.scrollTape(); } setTimeout(() => { @@ -87,13 +92,13 @@ const debouncedCaretUpdate = debounce(250, async () => { }, 250); }); -const throttledCaretHide = throttle(250, () => { +const throttledEvent = throttle(250, () => { Caret.hide(); }); $(window).on("resize", () => { - throttledCaretHide(); - debouncedCaretUpdate(); + throttledEvent(); + debouncedEvent(); }); ConfigEvent.subscribe((eventKey) => {