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
This commit is contained in:
schroda
2025-01-31 01:54:39 +01:00
parent 2c4a17b32f
commit dc9f6fc863

View File

@@ -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;
}