Skip to content

Commit

Permalink
revert trap focus changes
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Jun 18, 2019
1 parent 69420df commit 6ebe7f6
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions packages/material-ui/src/Modal/TrapFocus.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ function TrapFocus(props) {
const sentinelStart = React.useRef(null);
const sentinelEnd = React.useRef(null);
const nodeToRestore = React.useRef();
const isEnabledRef = React.useRef();
useEnhancedEffect(() => {
isEnabledRef.current = isEnabled;
}, []);

const rootRef = React.useRef(null);
// can be removed once we drop support for non ref forwarding class components
Expand Down Expand Up @@ -74,7 +70,7 @@ function TrapFocus(props) {
}

const contain = () => {
if (disableEnforceFocus || !isEnabledRef.current() || ignoreNextEnforceFocus.current) {
if (disableEnforceFocus || !isEnabled() || ignoreNextEnforceFocus.current) {
ignoreNextEnforceFocus.current = false;
return;
}
Expand All @@ -86,7 +82,7 @@ function TrapFocus(props) {

const loopFocus = event => {
// 9 = Tab
if (disableEnforceFocus || !isEnabledRef.current() || event.keyCode !== 9) {
if (disableEnforceFocus || !isEnabled() || event.keyCode !== 9) {
return;
}

Expand Down Expand Up @@ -123,7 +119,7 @@ function TrapFocus(props) {
nodeToRestore.current = null;
}
};
}, [disableAutoFocus, disableEnforceFocus, disableRestoreFocus, open]);
}, [disableAutoFocus, disableEnforceFocus, disableRestoreFocus, isEnabled, open]);

return (
<React.Fragment>
Expand Down

0 comments on commit 6ebe7f6

Please sign in to comment.