diff --git a/src/modal/modal.directive.ts b/src/modal/modal.directive.ts index fcf97a1e37..b50cfa21cc 100644 --- a/src/modal/modal.directive.ts +++ b/src/modal/modal.directive.ts @@ -371,9 +371,8 @@ export class ModalDirective implements OnDestroy, OnInit { // } protected focusOtherModal() { - const otherOpenedModals = this._element.nativeElement.parentElement.querySelectorAll( - '.in[bsModal]' - ); + if (this._element.nativeElement.parentElement == null) return; + const otherOpenedModals = this._element.nativeElement.parentElement.querySelectorAll('.in[bsModal]'); if (!otherOpenedModals.length) { return; }