@@ -55,6 +55,7 @@ export default class ModalPortal extends Component {
55
55
onAfterOpen : PropTypes . func ,
56
56
onAfterClose : PropTypes . func ,
57
57
onRequestClose : PropTypes . func ,
58
+ onOverlayRightClick : PropTypes . func ,
58
59
closeTimeoutMS : PropTypes . number ,
59
60
shouldFocusAfterRender : PropTypes . bool ,
60
61
shouldCloseOnOverlayClick : PropTypes . bool ,
@@ -299,6 +300,15 @@ export default class ModalPortal extends Component {
299
300
this . shouldClose = null ;
300
301
} ;
301
302
303
+ handleOverlayRightClick = ( event ) => {
304
+ if ( this . shouldClose === null ) this . shouldClose = true ;
305
+ else if ( ! this . shouldClose ) this . shouldClose = null ;
306
+ if ( this . shouldClose ) {
307
+ event . preventDefault ( ) ;
308
+ this . props . onOverlayRightClick ( event ) ;
309
+ }
310
+ } ;
311
+
302
312
handleContentOnMouseUp = ( ) => {
303
313
this . shouldClose = false ;
304
314
} ;
@@ -375,7 +385,8 @@ export default class ModalPortal extends Component {
375
385
className : this . buildClassName ( "overlay" , overlayClassName ) ,
376
386
style : { ...overlayStyles , ...this . props . style . overlay } ,
377
387
onClick : this . handleOverlayOnClick ,
378
- onMouseDown : this . handleOverlayOnMouseDown
388
+ onMouseDown : this . handleOverlayOnMouseDown ,
389
+ onContextMenu : this . handleOverlayRightClick ,
379
390
} ;
380
391
381
392
const contentProps = {
0 commit comments