@@ -50,6 +50,7 @@ import {
5050 applySafeAreaOverrides ,
5151 clearSafeAreaOverrides ,
5252 getRootSafeAreaTop ,
53+ hasCustomModalDimensions ,
5354 type ModalSafeAreaContext ,
5455} from './safe-area-utils' ;
5556import { setCardStatusBarDark , setCardStatusBarDefault } from './utils' ;
@@ -312,11 +313,8 @@ export class Modal implements ComponentInterface, OverlayInterface {
312313 this . updateSafeAreaOverrides ( ) ;
313314
314315 // Re-evaluate fullscreen safe-area padding: clear first, then re-apply.
315- // Single findContentAndFooter() call avoids redundant DOM traversal.
316316 const { contentEl, hasFooter } = this . findContentAndFooter ( ) ;
317- if ( contentEl ) {
318- contentEl . style . removeProperty ( '--ion-content-safe-area-padding-bottom' ) ;
319- }
317+ this . clearContentSafeAreaPadding ( contentEl ) ;
320318 this . applyFullscreenSafeAreaTo ( contentEl , hasFooter ) ;
321319 }
322320 } , 50 ) ; // Debounce to avoid excessive calls during active resizing
@@ -1430,6 +1428,11 @@ export class Modal implements ComponentInterface, OverlayInterface {
14301428
14311429 /**
14321430 * Creates the context object for safe-area utilities.
1431+ *
1432+ * `hasCustomDimensions` is only set by `setInitialSafeAreaOverrides()`
1433+ * because it is only read by `getInitialSafeAreaConfig()`. Other callers
1434+ * (resize handler, post-animation update, fullscreen-padding apply) would
1435+ * pay a `getComputedStyle()` cost for a value they never consult.
14331436 */
14341437 private getSafeAreaContext ( ) : ModalSafeAreaContext {
14351438 return {
@@ -1452,7 +1455,10 @@ export class Modal implements ComponentInterface, OverlayInterface {
14521455 * sheets to prevent header content from getting double-offset padding).
14531456 */
14541457 private setInitialSafeAreaOverrides ( ) : void {
1455- const context = this . getSafeAreaContext ( ) ;
1458+ const context : ModalSafeAreaContext = {
1459+ ...this . getSafeAreaContext ( ) ,
1460+ hasCustomDimensions : hasCustomModalDimensions ( this . el ) ,
1461+ } ;
14561462 const safeAreaConfig = getInitialSafeAreaConfig ( context ) ;
14571463 applySafeAreaOverrides ( this . el , safeAreaConfig ) ;
14581464
@@ -1526,14 +1532,13 @@ export class Modal implements ComponentInterface, OverlayInterface {
15261532 }
15271533
15281534 /**
1529- * Clears --ion-content-safe-area-padding-bottom from ion-content inside
1530- * this modal.
1535+ * Removes the internal --ion-content-safe-area-padding-bottom property
1536+ * from an already-located ion-content. Callers do their own
1537+ * findContentAndFooter() so they can also read hasFooter if needed.
15311538 */
1532- private clearContentSafeAreaPadding ( ) : void {
1533- const { contentEl } = this . findContentAndFooter ( ) ;
1534- if ( contentEl ) {
1535- contentEl . style . removeProperty ( '--ion-content-safe-area-padding-bottom' ) ;
1536- }
1539+ private clearContentSafeAreaPadding ( contentEl : HTMLElement | null ) : void {
1540+ if ( ! contentEl ) return ;
1541+ contentEl . style . removeProperty ( '--ion-content-safe-area-padding-bottom' ) ;
15371542 }
15381543
15391544 /**
@@ -1553,7 +1558,6 @@ export class Modal implements ComponentInterface, OverlayInterface {
15531558 for ( const child of Array . from ( this . el . children ) ) {
15541559 if ( child . tagName === 'ION-CONTENT' ) contentEl = child as HTMLElement ;
15551560 if ( child . tagName === 'ION-FOOTER' ) hasFooter = true ;
1556- // Only search grandchildren for content if we haven't found one yet
15571561 for ( const grandchild of Array . from ( child . children ) ) {
15581562 if ( grandchild . tagName === 'ION-CONTENT' && ! contentEl ) contentEl = grandchild as HTMLElement ;
15591563 if ( grandchild . tagName === 'ION-FOOTER' ) hasFooter = true ;
@@ -1571,14 +1575,8 @@ export class Modal implements ComponentInterface, OverlayInterface {
15711575 // Remove internal sheet offset property
15721576 this . el . style . removeProperty ( '--ion-modal-offset-top' ) ;
15731577
1574- // Remove legacy wrapper styles (kept for safety in case they were
1575- // set before a live update applied this fix)
1576- if ( this . wrapperEl ) {
1577- this . wrapperEl . style . removeProperty ( 'height' ) ;
1578- this . wrapperEl . style . removeProperty ( 'padding-bottom' ) ;
1579- }
1580-
1581- this . clearContentSafeAreaPadding ( ) ;
1578+ const { contentEl } = this . findContentAndFooter ( ) ;
1579+ this . clearContentSafeAreaPadding ( contentEl ) ;
15821580 }
15831581
15841582 render ( ) {
0 commit comments