You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Overlays rendered into a second window (window.open, Document Picture-in-Picture) are positioned against the opener window #10951
When a React tree is portaled into another window's document, such as a popup from window.open() or a Document Picture-in-Picture window, overlay positioning uses the opener's window globals. Popovers and menus then show up in the wrong place, stay at 0,0 or close unexpectedly. This is a specific case of #4634.
🤔 Expected Behavior
Overlay positioning, resize handling and close-on-scroll use the window that owns the overlay and trigger elements (element.ownerDocument.defaultView).
😯 Current Behavior
Overlays in a second window read the opener's globals in four places:
overlays/calculatePosition.ts: viewport size and the instanceof HTMLElement containing-block check
overlays/useOverlayPosition.ts: resize listener on the opener window
overlays/useCloseOnScroll.ts: instanceof Node / HTMLInputElement checks, so any scroll in the second window closes the overlay
utils/useResizeObserver.ts: the opener's ResizeObserver, which doesn't fire for the second window while the opener tab is hidden (measured in Chrome Document PiP), so an overlay placed at 0,0 on first layout stays there
💁 Possible Solution
Resolve the window from the element (element.ownerDocument.defaultView), as getOwnerWindow already does. We're running this as a local patch.
🔦 Context
We portal part of our UI into a Document Picture-in-Picture window in Chrome, and into a second BrowserWindow in Electron. Menus and popovers inside it hit all four problems above.
Activity