From dc9f6fc8630dd001ae4294a80a4142f6237653b1 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Fri, 31 Jan 2025 01:54:39 +0100 Subject: [PATCH] Fix "Uncaught ResizeObserver loop completed with undelivered notifications" error Was caused due to creating a temporary div inside a resize observer callback. By moving the temp div outside the viewport, it does not the trigger resize observer again --- src/modules/core/utils/MediaQuery.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/core/utils/MediaQuery.tsx b/src/modules/core/utils/MediaQuery.tsx index acaf757e..10d2a256 100644 --- a/src/modules/core/utils/MediaQuery.tsx +++ b/src/modules/core/utils/MediaQuery.tsx @@ -37,6 +37,8 @@ export class MediaQuery { private static getScrollbarSize(type: 'height' | 'width'): number { const outer = document.createElement('div'); + outer.style.position = 'absolute'; + outer.style.top = '-9999px'; outer.style.visibility = 'hidden'; outer.style.overflow = 'scroll'; document.body.appendChild(outer); @@ -49,7 +51,7 @@ export class MediaQuery { const width = outer.offsetWidth - inner.offsetWidth; const height = outer.offsetHeight - inner.offsetHeight; - outer.parentNode?.removeChild(outer); + document.body.removeChild(outer); return type === 'height' ? height : width; }