Menu, ContextMenu, TieredMenu, OverlayPanel: Click outside of menu does not close component, when rendered in a different browsing context (e.g. window.open) #7441
When a menu is rendered in a newly created window (using window.open()), the menu does not close when clicking outside of the menu (which is the normal behavior when rendered in the main window).
This seems to be due to the usage of useEventListener and useOverlayListener without specifying target, which then defaults to document/'window'. However in this case, it should be the ownerDocument of the menu or the respective window.
Reproducer
StackBlitz does not support window.open() properly
Describe the bug
When a menu is rendered in a newly created window (using window.open()), the menu does not close when clicking outside of the menu (which is the normal behavior when rendered in the main window). This seems to be due to the usage of
useEventListener
anduseOverlayListener
without specifyingtarget
, which then defaults todocument
/'window'. However in this case, it should be theownerDocument
of the menu or the respective window.Reproducer
StackBlitz does not support window.open() properly
System Information
Steps to reproduce the behavior
StackBlitz unfortuantely always returns null when calling
window.open()
, but here is the code:Expected behavior
In popup windows, menu should just behave as in the normal browser window, i.e. close when clicking outside of the window