Skip to content

Commit

Permalink
fix: event propogation in react 17
Browse files Browse the repository at this point in the history
In react 17 the order of events changed. Trap was previously capturing the event which caused
issues like being unable to focus on content that is inside a portal.

re theKashey#134
  • Loading branch information
johnathanludwig committed Jul 2, 2021
1 parent a17cf97 commit 63f84fa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Trap.js
Expand Up @@ -171,13 +171,13 @@ const onWindowBlur = () => {
};

const attachHandler = () => {
document.addEventListener('focusin', onTrap, true);
document.addEventListener('focusin', onTrap);
document.addEventListener('focusout', onBlur);
window.addEventListener('blur', onWindowBlur);
};

const detachHandler = () => {
document.removeEventListener('focusin', onTrap, true);
document.removeEventListener('focusin', onTrap);
document.removeEventListener('focusout', onBlur);
window.removeEventListener('blur', onWindowBlur);
};
Expand Down

0 comments on commit 63f84fa

Please sign in to comment.