Skip to content

Commit b25283c

Browse files
authored
fix(cdk/a11y): error on firefox (#23395)
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.
1 parent e82ff91 commit b25283c

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/cdk/a11y/focus-trap/event-listener-inert-strategy.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ export class EventListenerFocusTrapInertStrategy implements FocusTrapInertStrate
5252

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

0 commit comments

Comments
 (0)