Skip to content

Commit

Permalink
check if dialog is connected before calling getBoundingClientRect
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Dec 19, 2024
1 parent 893ea9f commit 252296a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions ui/common/src/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down

0 comments on commit 252296a

Please sign in to comment.