From eebd143a9ff277ac9536c7c51e3fee5490ccfc72 Mon Sep 17 00:00:00 2001 From: Austin S <17107540+Aquafina-water-bottle@users.noreply.github.com> Date: Wed, 17 May 2023 00:52:38 -0600 Subject: [PATCH] Fix null error on window resizing (#2501) * Fix null error on window resizing * Be more specific in type cast (dae) --- CONTRIBUTORS | 1 + ts/reviewer/image_occlusion.ts | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 555a229ae..885cf9d8f 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -120,6 +120,7 @@ Ben Kerman Euan Kemp Kieran Black XeR +Austin Siew ******************** diff --git a/ts/reviewer/image_occlusion.ts b/ts/reviewer/image_occlusion.ts index b0a83034b..319e27221 100644 --- a/ts/reviewer/image_occlusion.ts +++ b/ts/reviewer/image_occlusion.ts @@ -12,7 +12,11 @@ export function setupImageCloze(): void { } function setupImageClozeInner(): void { - const canvas: HTMLCanvasElement = document.querySelector("canvas")! as HTMLCanvasElement; + const canvas = document.querySelector("canvas") as HTMLCanvasElement | null; + if (canvas == null) { + return; + } + canvas.style.maxWidth = "100%"; canvas.style.maxHeight = "95vh";