Skip to content

Commit

Permalink
[Modal] Fix concurrency regression (#13743)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari authored Nov 29, 2018
1 parent d8a7189 commit cd9c730
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions packages/material-ui/src/Modal/Modal.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { assert } from 'chai';
import { spy, stub } from 'sinon';
import PropTypes from 'prop-types';
import keycode from 'keycode';
import consoleErrorMock from 'test/utils/consoleErrorMock';
import { createShallow, createMount, getClasses, unwrap } from '@material-ui/core/test-utils';
Expand Down Expand Up @@ -514,4 +515,30 @@ describe('<Modal />', () => {
assert.strictEqual(handleRendered.callCount, 1);
});
});

describe('two modal at the same time', () => {
it('should open and close', () => {
const TestCase = props => (
<React.Fragment>
<Modal open={props.open}>
<div>Hello</div>
</Modal>
<Modal open={props.open}>
<div>World</div>
</Modal>
</React.Fragment>
);

TestCase.propTypes = {
open: PropTypes.bool,
};

const wrapper = mount(<TestCase open={false} />);
assert.strictEqual(document.body.style.overflow, '');
wrapper.setProps({ open: true });
assert.strictEqual(document.body.style.overflow, 'hidden');
wrapper.setProps({ open: false });
assert.strictEqual(document.body.style.overflow, '');
});
});
});
2 changes: 1 addition & 1 deletion packages/material-ui/src/Modal/ModalManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class ModalManager {
const containerIdx = findIndexOf(this.data, item => item.modals.indexOf(modal) !== -1);
const data = this.data[containerIdx];

if (data.modals.length === 1 && this.handleContainerOverflow) {
if (!data.style && this.handleContainerOverflow) {
setContainerStyle(data);
}
}
Expand Down

0 comments on commit cd9c730

Please sign in to comment.