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

Overlay mouse up event closes modal #633

Closed
WemkoDijkhuis opened this issue Mar 27, 2018 · 1 comment · Fixed by #634
Closed

Overlay mouse up event closes modal #633

WemkoDijkhuis opened this issue Mar 27, 2018 · 1 comment · Fixed by #634

Comments

@WemkoDijkhuis
Copy link
Contributor

WemkoDijkhuis commented Mar 27, 2018

Summary:

The modal closes unexpectedly. I want the modal to close only on an mouse click on the overlay. But when I do a mouse down event on the content, drag it to the overlay and release the mouse button the overlay is closed. This is a problem for me because we have a slider on the modal page and customers often drag the mouse outside the boundaries of the modal-content.

Steps to reproduce:

  1. Do mouse down on conent
  2. Drag mouse position to the overlay
  3. Release mouse down so that it fires an mouseUp event.
  4. The modal closes

Expected behavior:

Modal does not close on an mouseup event

Link to example of issue:

https://codesandbox.io/s/1qzjzzl6wj

Additional notes:

I wanted to create a pull request but my permission was denied. I thought it was open source since the contribution readme. I've got it working by deleting some code that didn't make sense for me.

For example:

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

Here there is a check for moveFromContentToOverlay but the check is overruled by the next check. I removed the moveFromContentToOverlay, handleOverlayOnMouseUp and the onMouseUp of the overlay. And then it worked like a charm.

@diasbruno
Copy link
Collaborator

diasbruno commented Mar 27, 2018

@WemkoDijkhuis To contribute, you can fork react-modal project and push the branch with the fix to your clone. Then you will be able to create a pull request.

This is not a close project and contribution is always welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants