@@ -16,21 +16,25 @@ type PopupShowInput = {
1616
1717type PopupHandlerOptions = {
1818 width ?: string ;
19+ height ?: string ;
1920 isClosable ?: boolean ;
2021} ;
2122
2223export class PopupHandler {
2324 private popup : A11yDialog | null = null ;
25+ private height : string | undefined ;
2426
25- constructor ( { width, isClosable} : PopupHandlerOptions ) {
27+ constructor ( { width, height , isClosable} : PopupHandlerOptions ) {
2628 if ( document . querySelector ( `#${ CONTAINER_ID } ` ) ) {
2729 throw new Error ( "Multiple instances of Authsignal popup is not supported." ) ;
2830 }
2931
30- this . create ( { width, isClosable} ) ;
32+ this . height = height ;
33+
34+ this . create ( { width, height, isClosable} ) ;
3135 }
3236
33- create ( { width = DEFAULT_WIDTH , isClosable = true } : PopupHandlerOptions ) {
37+ create ( { width = DEFAULT_WIDTH , height , isClosable = true } : PopupHandlerOptions ) {
3438 const isWidthValidCSSValue = CSS . supports ( "width" , width ) ;
3539
3640 let popupWidth = width ;
@@ -102,8 +106,8 @@ export class PopupHandler {
102106 width: 1px;
103107 min-width: 100%;
104108 border-radius: inherit;
105- max-height: 95vh;
106- height: ${ INITIAL_HEIGHT } ;
109+ max-height: ${ height ? "100%" : " 95vh" } ;
110+ height: ${ height ?? INITIAL_HEIGHT } ;
107111 }
108112 ` ;
109113
@@ -157,7 +161,10 @@ export class PopupHandler {
157161 dialogContent . appendChild ( iframe ) ;
158162 }
159163
160- window . addEventListener ( "message" , resizeIframe ) ;
164+ // Dynamic resizing if no height is set.
165+ if ( ! this . height ) {
166+ window . addEventListener ( "message" , resizeIframe ) ;
167+ }
161168
162169 this . popup ?. show ( ) ;
163170 }
@@ -179,6 +186,10 @@ export class PopupHandler {
179186 }
180187}
181188
189+ /**
190+ * Resize the iframe to the height of the pre-built UI's (#widget_container)
191+ * @param event MessageEvent
192+ */
182193function resizeIframe ( event : MessageEvent ) {
183194 const iframeEl = document . querySelector < HTMLIFrameElement > ( `#${ IFRAME_ID } ` ) ;
184195
0 commit comments