diff --git a/packages/main/src/Popover.ts b/packages/main/src/Popover.ts index 70eca0db7b5b..39d74d52d9bd 100644 --- a/packages/main/src/Popover.ts +++ b/packages/main/src/Popover.ts @@ -301,13 +301,13 @@ class Popover extends Popup { return opener; } - const rootNode = this.getRootNode(); + let rootNode = this.getRootNode(); - if (!(rootNode instanceof ShadowRoot || rootNode instanceof Document)) { - return; + if (rootNode === this) { + rootNode = document; } - let openerHTMLElement = rootNode.getElementById(opener); + let openerHTMLElement = (rootNode as Document | ShadowRoot).getElementById(opener); if (rootNode instanceof ShadowRoot && !openerHTMLElement) { openerHTMLElement = document.getElementById(opener); diff --git a/packages/main/test/pages/PopoverInitiallyOpen.html b/packages/main/test/pages/PopoverInitiallyOpen.html index 85b8ab8ae68b..1b1a31b4ed54 100644 --- a/packages/main/test/pages/PopoverInitiallyOpen.html +++ b/packages/main/test/pages/PopoverInitiallyOpen.html @@ -5,7 +5,7 @@ - Dialog + Popover Initially Open