File tree 3 files changed +22
-1
lines changed
3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 1
1
import { isClickInRect } from "@ui5/webcomponents-base/dist/util/PopupUtils.js" ;
2
2
import type { Interval } from "@ui5/webcomponents-base/dist/types.js" ;
3
+ import getActiveElement from "@ui5/webcomponents-base/dist/util/getActiveElement.js" ;
3
4
import type Popover from "../Popover.js" ;
4
5
import { instanceOfPopover } from "../Popover.js" ;
5
6
import { getOpenedPopups , addOpenedPopup , removeOpenedPopup } from "./OpenedPopupsRegistry.js" ;
@@ -20,7 +21,7 @@ const repositionPopovers = () => {
20
21
} ;
21
22
22
23
const closePopoversIfLostFocus = ( ) => {
23
- if ( document . activeElement ! . tagName === "IFRAME" ) {
24
+ if ( getActiveElement ( ) ! . tagName === "IFRAME" ) {
24
25
getRegistry ( ) . reverse ( ) . forEach ( popup => popup . instance . close ( false , false , true ) ) ;
25
26
}
26
27
} ;
Original file line number Diff line number Diff line change 26
26
27
27
< body class ="popover2auto ">
28
28
< iframe id ="clickThisIframe " src ="//localhost:8080 "> </ iframe >
29
+ < div id ="host ">
30
+ < template shadowrootmode ="open ">
31
+ < span > I'm in the shadow DOM</ span >
32
+ < iframe id ="clickThisIframeInsideShadowRoot " src ="//localhost:8080 "> </ iframe >
33
+ </ template >
34
+ </ div >
29
35
< ui5-button id ="btn "> Click me !</ ui5-button >
30
36
31
37
< ui5-popover id ="pop " class ="popover6auto " placement-type ="Top " accessible-name ="This popover is important ">
Original file line number Diff line number Diff line change @@ -363,6 +363,20 @@ describe("Popover general interaction", () => {
363
363
assert . notOk ( await popover . isDisplayedInViewport ( ) , "Popover is closed." ) ;
364
364
} ) ;
365
365
366
+ it ( "tests clicking on an iframe inside a shadow root closes the popover" , async ( ) => {
367
+ const btnOpenPopover = await browser . $ ( "#btn" ) ;
368
+ await btnOpenPopover . click ( ) ;
369
+
370
+ const popover = await browser . $ ( "#pop" ) ;
371
+ const iframe = await browser . $ ( "#host" ) . shadow$ ( "#clickThisIframeInsideShadowRoot" ) ;
372
+
373
+ assert . ok ( await popover . isDisplayedInViewport ( ) , "Popover is opened." ) ;
374
+
375
+ await iframe . click ( ) ;
376
+
377
+ assert . notOk ( await popover . isDisplayedInViewport ( ) , "Popover is closed." ) ;
378
+ } ) ;
379
+
366
380
it ( "Test initial focus when content is provided after the header and footer" , async ( ) => {
367
381
const listContainerItem = await browser . $ ( "#popoverFocusButton" ) ;
368
382
await listContainerItem . scrollIntoView ( ) ;
You can’t perform that action at this time.
0 commit comments