@@ -310,6 +310,26 @@ export class Content implements ComponentInterface {
310310 return forceOverscroll === undefined ? mode === 'ios' && isPlatform ( 'ios' ) : forceOverscroll ;
311311 }
312312
313+ /**
314+ * Whether this component should size itself to its contents height, which
315+ * is the case inside any popover and inside a modal whose `--height` is a
316+ * content-based value. Those overlays give the content no definite height
317+ * to fill.
318+ */
319+ private shouldSizeToContent ( ) {
320+ if ( hostContext ( 'ion-popover' , this . el ) ) {
321+ return true ;
322+ }
323+
324+ const modal = this . el . closest ( 'ion-modal' ) ;
325+ if ( modal === null ) {
326+ return false ;
327+ }
328+
329+ const height = getComputedStyle ( modal ) . getPropertyValue ( '--height' ) . trim ( ) ;
330+ return CONTENT_SIZED_HEIGHTS . includes ( height ) ;
331+ }
332+
313333 private resize ( ) {
314334 /**
315335 * Only force update if the component is rendered in a browser context.
@@ -538,7 +558,7 @@ export class Content implements ComponentInterface {
538558 class = { createColorClasses ( this . color , {
539559 [ mode ] : true ,
540560 'content-fullscreen' : this . fullscreen ,
541- 'content-sizing' : hostContext ( 'ion-popover' , this . el ) ,
561+ 'content-sizing' : this . shouldSizeToContent ( ) ,
542562 overscroll : forceOverscroll ,
543563 [ `content-${ rtl } ` ] : true ,
544564 } ) }
@@ -579,6 +599,12 @@ export class Content implements ComponentInterface {
579599 }
580600}
581601
602+ /**
603+ * `ion-modal` `--height` values that size the modal to its contents, leaving
604+ * children an indefinite height to resolve against.
605+ */
606+ const CONTENT_SIZED_HEIGHTS = [ 'auto' , 'fit-content' , 'min-content' , 'max-content' ] ;
607+
582608const getParentElement = ( el : any ) => {
583609 if ( el . parentElement ) {
584610 // normal element with a parent element
0 commit comments