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

Added close modal on right click #961

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[Added] Modal close on righlt click on overlay
ZainGulbaz committed Aug 21, 2022
commit 8eeec3232cc0e5f004fd7aa34df9027cff474cb0
13 changes: 12 additions & 1 deletion src/components/ModalPortal.js
Original file line number Diff line number Diff line change
@@ -299,6 +299,16 @@ export default class ModalPortal extends Component {
this.shouldClose = null;
};

handleOverlayOnContextMenu = event => {
if(this.shouldClose===null)this.shouldClose=true;
else if(!this.shouldClose) this.shouldClose=null;
if(this.shouldClose)
{
event.preventDefault();
this.requestClose(event);
}
};

handleContentOnMouseUp = () => {
this.shouldClose = false;
};
@@ -375,7 +385,8 @@ export default class ModalPortal extends Component {
className: this.buildClassName("overlay", overlayClassName),
style: { ...overlayStyles, ...this.props.style.overlay },
onClick: this.handleOverlayOnClick,
onMouseDown: this.handleOverlayOnMouseDown
onMouseDown: this.handleOverlayOnMouseDown,
onContextMenu: this.handleOverlayOnContextMenu,
};

const contentProps = {