Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fixed] Enable click to close in iOS (#301) (#304) #313

Merged
merged 1 commit into from
Feb 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 4 additions & 13 deletions lib/components/ModalPortal.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,10 @@ export default class ModalPortal extends Component {
}
}

handleOverlayMouseDown = () => {
handleOverlayOnClick = (event) => {
if (this.shouldClose === null) {
this.shouldClose = true;
}
}

handleOverlayMouseUp = (event) => {
if (this.shouldClose && this.props.shouldCloseOnOverlayClick) {
if (this.ownerHandlesClose()) {
this.requestClose(event);
Expand All @@ -170,11 +167,7 @@ export default class ModalPortal extends Component {
this.shouldClose = null;
}

handleContentMouseDown = () => {
this.shouldClose = false;
}

handleContentMouseUp = () => {
handleContentOnClick = () => {
this.shouldClose = false;
}

Expand Down Expand Up @@ -217,17 +210,15 @@ export default class ModalPortal extends Component {
ref={(c) => { this.overlay = c; }}
className={this.buildClassName('overlay', this.props.overlayClassName)}
style={Assign({}, overlayStyles, this.props.style.overlay || {})}
onMouseDown={this.handleOverlayMouseDown}
onMouseUp={this.handleOverlayMouseUp}
onClick={this.handleOverlayOnClick}
>
<div
ref={(c) => { this.content = c; }}
style={Assign({}, contentStyles, this.props.style.content || {})}
className={this.buildClassName('content', this.props.className)}
tabIndex={-1}
onKeyDown={this.handleKeyDown}
onMouseDown={this.handleContentMouseDown}
onMouseUp={this.handleContentMouseUp}
onClick={this.handleContentOnClick}
role={this.props.role}
aria-label={this.props.contentLabel}
>
Expand Down
9 changes: 3 additions & 6 deletions specs/Modal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,7 @@ describe('Modal', () => {
expect(modal.props.isOpen).toEqual(true);
const overlay = TestUtils.scryRenderedDOMComponentsWithClass(modal.portal, 'ReactModal__Overlay');
expect(overlay.length).toEqual(1);
Simulate.mouseDown(overlay[0]); // click the overlay
Simulate.mouseUp(overlay[0]);
Simulate.click(overlay[0]); // click the overlay
expect(!requestCloseCallback.called).toBeTruthy();
});

Expand All @@ -338,8 +337,7 @@ describe('Modal', () => {
expect(modal.props.isOpen).toEqual(true);
const overlay = TestUtils.scryRenderedDOMComponentsWithClass(modal.portal, 'ReactModal__Overlay');
expect(overlay.length).toEqual(1);
Simulate.mouseDown(overlay[0]); // click the overlay
Simulate.mouseUp(overlay[0]);
Simulate.click(overlay[0]); // click the overlay
expect(requestCloseCallback.called).toBeTruthy();
});

Expand Down Expand Up @@ -413,8 +411,7 @@ describe('Modal', () => {
const overlay = TestUtils.scryRenderedDOMComponentsWithClass(modal.portal, 'ReactModal__Overlay');
expect(overlay.length).toEqual(1);
// click the overlay
Simulate.mouseDown(overlay[0]);
Simulate.mouseUp(overlay[0], {
Simulate.click(overlay[0], {
// Used to test that this was the event received
fakeData: 'ABC'
});
Expand Down