From 81afc9202220dd247b93a98603eba72a0130f521 Mon Sep 17 00:00:00 2001 From: Miodec Date: Fri, 27 Jan 2023 15:28:08 +0100 Subject: [PATCH] returning if word is undefined --- frontend/src/ts/ui.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/src/ts/ui.ts b/frontend/src/ts/ui.ts index f798a5e5b..12a2f2a6d 100644 --- a/frontend/src/ts/ui.ts +++ b/frontend/src/ts/ui.ts @@ -88,11 +88,12 @@ const debouncedEvent = debounce(250, async () => { if (Config.tapeMode !== "off") { TestUI.scrollTape(); } else { - const currentTop: number = Math.floor( + const word = document.querySelectorAll("#words .word")[ TestUI.currentWordElementIndex - 1 - ].offsetTop - ); + ]; + if (!word) return; + const currentTop: number = Math.floor(word.offsetTop); TestUI.lineJump(currentTop); } }