Skip to content

Commit 1cbc9e5

Browse files
committed
fix: avoid crash on IE
Avoid crash on IE. Only focusable elements have a blur() function on IE, so we can sometimes crash here without a check.
1 parent 7a6c0c9 commit 1cbc9e5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Trap.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ const activateTrap = () => {
9595
)
9696
) {
9797
if (document && !lastActiveFocus && activeElement && !autoFocus) {
98-
activeElement.blur();
98+
// Check if blur() exists, which is missing on certain elements on IE
99+
if (activeElement.blur) {
100+
activeElement.blur();
101+
}
99102
document.body.focus();
100103
} else {
101104
result = moveFocusInside(workingArea, lastActiveFocus);

0 commit comments

Comments
 (0)