Skip to content

Commit 029d2a2

Browse files
committed
[TrapFocus] Don't contain if document isn't focused
1 parent b7bcfd3 commit 029d2a2

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

packages/material-ui/src/Modal/Modal.test.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,12 @@ describe('<Modal />', () => {
548548
clock.restore();
549549
});
550550

551-
it('contains the focus if the active element is removed', () => {
551+
it('contains the focus if the active element is removed', function test() {
552+
if (/jsdom/.test(window.navigator.userAgent)) {
553+
// see https://github.com/jsdom/jsdom/issues/2953
554+
this.skip();
555+
}
556+
552557
function WithRemovableElement({ hideButton = false }) {
553558
return (
554559
<Modal open>

packages/material-ui/src/Modal/TrapFocus.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ function TrapFocus(props) {
6767
}
6868

6969
const contain = () => {
70-
if (disableEnforceFocus || !isEnabled() || ignoreNextEnforceFocus.current) {
70+
if (
71+
!doc.hasFocus() ||
72+
disableEnforceFocus ||
73+
!isEnabled() ||
74+
ignoreNextEnforceFocus.current
75+
) {
7176
ignoreNextEnforceFocus.current = false;
7277
return;
7378
}

0 commit comments

Comments
 (0)