Skip to content

Commit

Permalink
fix: avoid crash on IE
Browse files Browse the repository at this point in the history
Avoid crash on IE. Only focusable elements have a blur() function on IE, so we can sometimes crash here without a check.
  • Loading branch information
leyanlo committed May 23, 2020
1 parent 7a6c0c9 commit 1cbc9e5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Trap.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ const activateTrap = () => {
)
) {
if (document && !lastActiveFocus && activeElement && !autoFocus) {
activeElement.blur();
// Check if blur() exists, which is missing on certain elements on IE
if (activeElement.blur) {
activeElement.blur();
}
document.body.focus();
} else {
result = moveFocusInside(workingArea, lastActiveFocus);
Expand Down

0 comments on commit 1cbc9e5

Please sign in to comment.