Skip to content

Commit

Permalink
fix(cdk/a11y): error on firefox (#23395)
Browse files Browse the repository at this point in the history
We seem to hitting an error on Firefox when calling `closest` inside a unit test. These changes add a null check to work around the issue.
  • Loading branch information
crisbeto committed Aug 18, 2021
1 parent e82ff91 commit b25283c
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/cdk/a11y/focus-trap/event-listener-inert-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ export class EventListenerFocusTrapInertStrategy implements FocusTrapInertStrate

// Don't refocus if target was in an overlay, because the overlay might be associated
// with an element inside the FocusTrap, ex. mat-select.
if (target && !focusTrapRoot.contains(target) &&
target.closest('div.cdk-overlay-pane') === null) {
if (target && !focusTrapRoot.contains(target) && !target.closest?.('div.cdk-overlay-pane')) {
// Some legacy FocusTrap usages have logic that focuses some element on the page
// just before FocusTrap is destroyed. For backwards compatibility, wait
// to be sure FocusTrap is still enabled before refocusing.
Expand Down

0 comments on commit b25283c

Please sign in to comment.