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 44976a0
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions packages/material-ui/src/Modal/TrapFocus.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import warning from 'warning';
import ownerDocument from '../utils/ownerDocument';
import { useForkRef } from '../utils/reactHelpers';

const useEnhancedEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;

/**
* @ignore - internal component.
*/
Expand All @@ -26,10 +24,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 +68,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 +80,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 +117,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 44976a0

Please sign in to comment.