react-modal icon indicating copy to clipboard operation
react-modal copied to clipboard

[Added] Modal Close on right click at overlay

Open ZainGulbaz opened this issue 2 years ago • 8 comments

Fixes #[837].

Changes proposed:

-Added a prop of function type 'onOverlayRightClick' that calls a function when ever we right click on modal's overlay. -The user can then change modal's state isOpen to false, if he wants to clocse the modal on right click at overlay - <Modal className="Modal__Bootstrap modal-dialog" isOpen={this.state.modalIsOpen} onRequestClose={this.handleModalCloseRequest} **onOverlayRightClick={this.handleModalCloseRequest}** >

Acceptance Checklist:

  • [ ] The commit message follows the guidelines in CONTRIBUTING.md.
  • [ ] Documentation (README.md) and examples have been updated as needed.
  • [ ] If this is a code change, a spec testing the functionality has been added.
  • [ ] If the commit message has [changed] or [removed], there is an upgrade path above.

ZainGulbaz avatar Aug 27 '22 13:08 ZainGulbaz

We are going in the right direction, just made some comments. It must be the last change. Obrigado pelo PR.

diasbruno avatar Aug 27 '22 23:08 diasbruno

Awesome!! :tada:

Can you include a test for this, please?

diasbruno avatar Aug 28 '22 03:08 diasbruno

@diasbruno I have added latest commit of example test case. Kindly let me know, if you have any suggestions.

ZainGulbaz avatar Aug 28 '22 12:08 ZainGulbaz

It looks great, but we also need to add an unit testing for this feature. Let me know if you need anything...

diasbruno avatar Aug 28 '22 19:08 diasbruno

Is there any unit testing already done?

ZainGulbaz avatar Oct 20 '22 02:10 ZainGulbaz

All unit tests are here https://github.com/reactjs/react-modal/tree/master/specs

diasbruno avatar Oct 20 '22 02:10 diasbruno

I'm sorry to interrupt, but I think it's awkward that the library provides click events. To ensure consistency, you should add all basic events such as onClick, onMouseMove before adding onOverlayRightClick.

To implement the functionality of closing the modal when the user right-clicks, you can make use of overlayRef.

honeymaro avatar Feb 23 '24 03:02 honeymaro

@honeymaro It depends.

You should use overlayRef only if you need to do something with the reference. In this case, having 2 options is not a terrible idea.

diasbruno avatar Feb 23 '24 23:02 diasbruno