@@ -172,6 +172,21 @@ export class UUIPopoverContainerElement extends LitElement {
172172 const isEnd = this . _actualPlacement . indexOf ( '-end' ) !== - 1 ;
173173
174174 const targetRect = this . #targetElement. getBoundingClientRect ( ) ;
175+
176+ // Clamp left and top within screen bounds
177+ // If the target leaves the screen, the popover follows.
178+ const screenWidth = window . innerWidth ;
179+ const screenHeight = window . innerHeight ;
180+
181+ if ( isBottomPlacement ) {
182+ const availableSpaceBelow =
183+ screenHeight - ( targetRect . top + targetRect . height ) - this . margin ;
184+ this . style . maxHeight = `${ Math . max ( 100 , availableSpaceBelow * 0.9 ) } px` ;
185+ } else if ( isTopPlacement ) {
186+ const availableSpaceAbove = targetRect . top - this . margin ;
187+ this . style . maxHeight = `${ Math . max ( 100 , availableSpaceAbove * 0.9 ) } px` ;
188+ }
189+
175190 const popoverRect = this . getBoundingClientRect ( ) ;
176191
177192 let top = 0 ;
@@ -226,11 +241,6 @@ export class UUIPopoverContainerElement extends LitElement {
226241 }
227242 }
228243
229- // Clamp left and top within screen bounds
230- // If the target leaves the screen, the popover follows.
231- const screenWidth = window . innerWidth ;
232- const screenHeight = window . innerHeight ;
233-
234244 const topTargetVsScreenTop = Math . min (
235245 0 ,
236246 targetRect . top + targetRect . height ,
@@ -417,7 +427,7 @@ export class UUIPopoverContainerElement extends LitElement {
417427 padding: 0;
418428 background- color : none;
419429 background: none;
420- overflow: v is ible ;
430+ overflow: au to ;
421431 color : var(- - uui- color - text);
422432 }
423433 ` ,
0 commit comments