File tree Expand file tree Collapse file tree 3 files changed +16
-9
lines changed
packages/uui-popover-container/lib Expand file tree Collapse file tree 3 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -10,10 +10,11 @@ export class UUIPopoverContainerShadowDomTesterElement extends LitElement {
10
10
return html `< div
11
11
style ="height: 500px; overflow: auto; outline: 1px solid black ">
12
12
< div
13
- style ="width: 300px; height: 300px; outline: 1px solid black; overflow: auto; ">
13
+ style ="position:relative; width: 300px; height: 300px; outline: 1px solid black; overflow: auto; ">
14
14
< div style ="height: 150px "> </ div >
15
15
< uui-button
16
16
id ="popover-button "
17
+ style ="position: absolute; top: 50px; left: 50px; "
17
18
popovertarget ="popover-container "
18
19
look ="primary "
19
20
label ="Open popover ">
@@ -28,7 +29,8 @@ export class UUIPopoverContainerShadowDomTesterElement extends LitElement {
28
29
< div
29
30
style ="width: 100%; background-color: var(--uui-color-surface); max-width: 200px; box-shadow: var(--uui-shadow-depth-4); padding: var(--uui-size-space-4); border-radius: var(--uui-border-radius); font-size: 0.9rem; ">
30
31
< h3 > Scroll!</ h3 >
31
- Scrolling in any of the 2 boxes should trigger an update
32
+ Scrolling in any of the 2 boxes that are in a shadow-dom inside 2
33
+ boxes should trigger an update
32
34
</ div >
33
35
</ uui-popover-container > ` ;
34
36
}
Original file line number Diff line number Diff line change @@ -359,6 +359,7 @@ export class UUIPopoverContainerElement extends LitElement {
359
359
style = getComputedStyle ( el ) ;
360
360
361
361
if ( excludeStaticParent && style . position === 'static' ) {
362
+ el = this . #getAncestorElement( el ) ;
362
363
continue ;
363
364
}
364
365
if (
@@ -370,16 +371,20 @@ export class UUIPopoverContainerElement extends LitElement {
370
371
return ;
371
372
}
372
373
373
- if ( el . parentElement ) {
374
- el = el . parentElement ;
375
- } else {
376
- // If we had no parentElement, then check for shadow roots:
377
- el = ( el . getRootNode ( ) as any ) ?. host ;
378
- }
374
+ el = this . #getAncestorElement( el ) ;
379
375
}
380
376
this . #scrollParents. push ( document . body ) ;
381
377
}
382
378
379
+ #getAncestorElement( el : HTMLElement | null ) : HTMLElement | null {
380
+ if ( el ?. parentElement ) {
381
+ return el . parentElement ;
382
+ } else {
383
+ // If we had no parentElement, then check for shadow roots:
384
+ return ( el ?. getRootNode ( ) as any ) ?. host ;
385
+ }
386
+ }
387
+
383
388
render ( ) {
384
389
return html `<slot> </ slot> ` ;
385
390
}
Original file line number Diff line number Diff line change @@ -230,7 +230,7 @@ export const InsideShadowDOMScrollContainer: Story = {
230
230
render : ( ) => html `
231
231
< div style ="height: 500px; overflow: auto; outline: 1px solid black ">
232
232
< div
233
- style ="width: 300px; height: 300px; outline: 1px solid black; overflow: auto; ">
233
+ style ="position:static; width: 300px; height: 300px; outline: 1px solid black; overflow: auto; ">
234
234
< div style ="height: 150px "> </ div >
235
235
< uui-popover-container-shadowdomtester > </ uui-popover-container-shadowdomtester >
236
236
< div style ="height: 150px "> </ div >
You can’t perform that action at this time.
0 commit comments