Skip to content

Commit 7b01b44

Browse files
committed
Add empty list check
1 parent fdd3d52 commit 7b01b44

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/modal/modal.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@ export class Modal implements AfterViewInit, OnInit, OnDestroy {
167167
primaryFocusElement.focus();
168168
return;
169169
}
170-
getFocusElementList(this.modal.nativeElement)[0].focus();
170+
if (getFocusElementList(this.modal.nativeElement).length > 0) {
171+
getFocusElementList(this.modal.nativeElement)[0].focus();
172+
} else {
173+
this.modal.nativeElement.focus();
174+
}
171175
}
172176

173177
/**

0 commit comments

Comments
 (0)