From 2e52b9af7093cc319c5c04f16df3a1bff072a21e Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Fri, 24 Apr 2026 13:53:13 +0700 Subject: [PATCH] fix ResizeObserver not working in a popout --- src/view/Layout.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/view/Layout.tsx b/src/view/Layout.tsx index 7361b5e9..a18509ae 100755 --- a/src/view/Layout.tsx +++ b/src/view/Layout.tsx @@ -263,8 +263,11 @@ export class LayoutInternal extends React.Component this.getScreenRect(r); - this.resizeObserver = new ResizeObserver(entries => { - requestAnimationFrame(() => { + // Spec says ResizeObserver triggers callback in the same window as the observed element, + // but it's just not true in Chrome, so, use ResizeObserver from PARENT window + const parentWindow = (this.currentDocument.defaultView ?? window); + this.resizeObserver = new parentWindow.ResizeObserver(entries => { + parentWindow.requestAnimationFrame(() => { this.updateRect(); }); }); @@ -279,7 +282,7 @@ export class LayoutInternal extends React.Component { this.updateRect(); }); - + this.resizeObserver.observe(this.currentWindow.document.documentElement); const sourceElement = this.props.mainLayout!.getRootDiv()!; const targetElement = this.selfRef.current!;