@@ -41,6 +41,16 @@ export class IfxModal {
4141 private modalContainer : HTMLElement ;
4242 private focusableElements : HTMLElement [ ] = [ ] ;
4343 private closeButton : HTMLButtonElement | HTMLIfxIconButtonElement ;
44+ private resizeTimeout : ReturnType < typeof setTimeout > ;
45+
46+ handleResize = ( ) => {
47+ clearTimeout ( this . resizeTimeout ) ;
48+ this . resizeTimeout = setTimeout ( ( ) => {
49+ if ( this . showModal ) {
50+ this . handleComponentOverflow ( ) ;
51+ }
52+ } , 100 ) ;
53+ } ;
4454
4555 async componentDidLoad ( ) {
4656 if ( ! isNestedInIfxComponent ( this . hostElement ) ) {
@@ -54,17 +64,22 @@ export class IfxModal {
5464 ( el ) => isHidden ( el ) || el . matches ( '[data-focus-trap-edge]' ) ,
5565 isFocusable
5666 ) ;
67+ window . addEventListener ( 'resize' , this . handleResize ) ;
5768 }
5869
70+ disconnectedCallback ( ) {
71+ window . removeEventListener ( 'resize' , this . handleResize ) ;
72+ }
73+
5974 componentWillRender ( ) {
6075 if ( this . showModal ) {
6176 this . handleComponentOverflow ( ) ;
6277 }
6378 }
6479
65- handleComponentOverflow ( ) {
80+ async handleComponentOverflow ( ) {
6681 const modalContentContainer = this . hostElement . shadowRoot . querySelector ( '.modal-content-container' ) ;
67- if ( this . showModal && this . isModalContentContainerHeightReachedViewport ( ) ) {
82+ if ( this . showModal && await this . isModalContentContainerHeightReachedViewport ( ) ) {
6883 modalContentContainer . classList . add ( 'no-overflow' )
6984 } else if ( modalContentContainer ?. classList . contains ( 'no-overflow' ) ) {
7085 modalContentContainer ?. classList . remove ( 'no-overflow' )
@@ -211,7 +226,8 @@ export class IfxModal {
211226 const modalContent = this . hostElement . shadowRoot . querySelector ( '.modal-content' ) as HTMLElement ;
212227 const modalContentHeight = modalContent . offsetHeight ;
213228 const viewportHeight = window . innerHeight ;
214- resolve ( modalContentHeight >= viewportHeight * 0.9 ) ;
229+ const extraMarginForEdgeBrowser = 3 ;
230+ resolve ( modalContentHeight + extraMarginForEdgeBrowser >= viewportHeight * 0.9 ) ;
215231 } , 100 ) ;
216232 } ) ;
217233}
0 commit comments