From 252296afde92c5c4df22d11e4b8589a8a0f1d239 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Thu, 19 Dec 2024 11:29:12 +0100 Subject: [PATCH] check if dialog is connected before calling getBoundingClientRect --- ui/common/src/dialog.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ui/common/src/dialog.ts b/ui/common/src/dialog.ts index e03422c46c170..6889cdcd1ab61 100644 --- a/ui/common/src/dialog.ts +++ b/ui/common/src/dialog.ts @@ -246,12 +246,11 @@ class DialogWrapper implements Dialog { const justThen = Date.now(); const cancelOnInterval = (e: PointerEvent) => { if (Date.now() - justThen < 200) return; - const r = dialog.getBoundingClientRect(); - if ( - dialog.isConnected && - (e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom) - ) - this.close('cancel'); + if (dialog.isConnected) { + const r = dialog.getBoundingClientRect(); + if (e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom) + this.close('cancel'); + } }; this.observer.observe(document.body, { childList: true, subtree: true }); view.parentElement?.style.setProperty('---viewport-height', `${window.innerHeight}px`);