@@ -32,7 +32,7 @@ import { ModalConfig, ModalSize } from "../classes/modal-config";
32
32
#modal>
33
33
34
34
<!-- Configurable close icon -->
35
- <i class="close icon" *ngIf=" isClosable" (click)="close()"></i>
35
+ <i class="close icon" [hidden]="! isClosable" (click)="close()"></i>
36
36
<!-- <ng-content> so that <sui-modal> can be used as a normal component. -->
37
37
<ng-content></ng-content>
38
38
<!-- @ViewChild reference so we can insert elements beside this div. -->
@@ -270,27 +270,29 @@ export class SuiModal<T, U> implements OnInit, AfterViewInit {
270
270
271
271
// Decides whether the modal needs to reposition to allow scrolling.
272
272
private updateScroll ( ) :void {
273
- // Semantic UI modal margin is 3.5rem, which is relative to the global font size, so for compatibility:
274
- const fontSize = parseFloat ( window . getComputedStyle ( document . documentElement ) . getPropertyValue ( "font-size" ) ) ;
275
- const margin = fontSize * 3.5 ;
276
-
277
- // _mustAlwaysScroll works by stopping _mustScroll from being automatically updated, so it stays `true`.
278
- if ( ! this . _mustAlwaysScroll && this . _modalElement ) {
279
- const element = this . _modalElement . nativeElement as Element ;
280
-
281
- // The modal must scroll if the window height is smaller than the modal height + both margins.
282
- this . _mustScroll = window . innerHeight < element . clientHeight + margin * 2 ;
273
+ if ( window ) {
274
+ // Semantic UI modal margin is 3.5rem, which is relative to the global font size, so for compatibility:
275
+ const fontSize = parseFloat ( window . getComputedStyle ( document . documentElement ) . getPropertyValue ( "font-size" ) ) ;
276
+ const margin = fontSize * 3.5 ;
277
+
278
+ // _mustAlwaysScroll works by stopping _mustScroll from being automatically updated, so it stays `true`.
279
+ if ( ! this . _mustAlwaysScroll && this . _modalElement ) {
280
+ const element = this . _modalElement . nativeElement as Element ;
281
+
282
+ // The modal must scroll if the window height is smaller than the modal height + both margins.
283
+ this . _mustScroll = window . innerHeight < element . clientHeight + margin * 2 ;
284
+ }
283
285
}
284
286
}
285
287
286
- public onClick ( e :MouseEvent ) :void {
288
+ public onClick ( e :any ) :void {
287
289
// Makes sense here, as the modal shouldn't be attached to any DOM element.
288
290
e . stopPropagation ( ) ;
289
291
}
290
292
291
293
// Document listener is fine here because nobody will enough modals open.
292
294
@HostListener ( "document:keyup" , [ "$event" ] )
293
- public onDocumentKeyUp ( e :KeyboardEvent ) :void {
295
+ public onDocumentKeyup ( e :any ) :void {
294
296
if ( e . keyCode === KeyCode . Escape ) {
295
297
// Close automatically covers case of `!isClosable`, so check not needed.
296
298
this . close ( ) ;
0 commit comments