Skip to content

Commit

Permalink
[fixed] Drag stop (mouseup) on Overlay closes Modal
Browse files Browse the repository at this point in the history
  • Loading branch information
silverbber authored and diasbruno committed Oct 6, 2017
1 parent a712d88 commit 4fa5628
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/components/ModalPortal.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default class ModalPortal extends Component {
};

this.shouldClose = null;
this.moveFromContentToOverlay = null;
}

componentDidMount() {
Expand Down Expand Up @@ -216,6 +217,21 @@ export default class ModalPortal extends Component {
}
}
this.shouldClose = null;
this.moveFromContentToOverlay = null;
}

handleOverlayOnMouseUp = () => {
if (this.moveFromContentToOverlay === null) {
this.shouldClose = false;
}
}

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

handleOverlayOnMouseDown = () => {
this.moveFromContentToOverlay = false;
}

handleContentOnClick = () => {
Expand All @@ -224,6 +240,7 @@ export default class ModalPortal extends Component {

handleContentOnMouseDown = () => {
this.shouldClose = false;
this.moveFromContentToOverlay = false;
}

requestClose = event =>
Expand Down Expand Up @@ -271,14 +288,17 @@ export default class ModalPortal extends Component {
ref={this.setOverlayRef}
className={this.buildClassName('overlay', overlayClassName)}
style={{ ...overlayStyles, ...this.props.style.overlay }}
onClick={this.handleOverlayOnClick}>
onClick={this.handleOverlayOnClick}
onMouseDown={this.handleOverlayOnMouseDown}
onMouseUp={this.handleOverlayOnMouseUp}>
<div
ref={this.setContentRef}
style={{ ...contentStyles, ...this.props.style.content }}
className={this.buildClassName('content', className)}
tabIndex="-1"
onKeyDown={this.handleKeyDown}
onMouseDown={this.handleContentOnMouseDown}
onMouseUp={this.handleContentOnMouseUp}
onClick={this.handleContentOnClick}
role={this.props.role}
aria-label={this.props.contentLabel}
Expand Down

0 comments on commit 4fa5628

Please sign in to comment.