Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 8d7ec06

Browse files
committed
fix(dialog): guard against missing focus traps upon removal.
1 parent cfdd7cf commit 8d7ec06

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/components/dialog/dialog.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,13 @@ function MdDialogProvider($$interimElementProvider) {
624624
options.hideBackdrop(options.$destroy);
625625

626626
// Remove the focus traps that we added earlier for keeping focus within the dialog.
627-
topFocusTrap.parentNode.removeChild(topFocusTrap);
628-
bottomFocusTrap.parentNode.removeChild(bottomFocusTrap);
627+
if (topFocusTrap && topFocusTrap.parentNode) {
628+
topFocusTrap.parentNode.removeChild(topFocusTrap);
629+
}
630+
631+
if (bottomFocusTrap && bottomFocusTrap.parentNode) {
632+
bottomFocusTrap.parentNode.removeChild(bottomFocusTrap);
633+
}
629634

630635
// For navigation $destroy events, do a quick, non-animated removal,
631636
// but for normal closes (from clicks, etc) animate the removal

0 commit comments

Comments
 (0)