@@ -65,6 +65,7 @@ export default class ModalPortal extends Component {
65
65
} ;
66
66
67
67
this . shouldClose = null ;
68
+ this . moveFromContentToOverlay = null ;
68
69
}
69
70
70
71
componentDidMount ( ) {
@@ -216,6 +217,21 @@ export default class ModalPortal extends Component {
216
217
}
217
218
}
218
219
this . shouldClose = null ;
220
+ this . moveFromContentToOverlay = null ;
221
+ }
222
+
223
+ handleOverlayOnMouseUp = ( ) => {
224
+ if ( this . moveFromContentToOverlay === null ) {
225
+ this . shouldClose = false ;
226
+ }
227
+ }
228
+
229
+ handleContentOnMouseUp = ( ) => {
230
+ this . shouldClose = false ;
231
+ }
232
+
233
+ handleOverlayOnMouseDown = ( ) => {
234
+ this . moveFromContentToOverlay = false ;
219
235
}
220
236
221
237
handleContentOnClick = ( ) => {
@@ -224,6 +240,7 @@ export default class ModalPortal extends Component {
224
240
225
241
handleContentOnMouseDown = ( ) => {
226
242
this . shouldClose = false ;
243
+ this . moveFromContentToOverlay = false ;
227
244
}
228
245
229
246
requestClose = event =>
@@ -271,14 +288,17 @@ export default class ModalPortal extends Component {
271
288
ref = { this . setOverlayRef }
272
289
className = { this . buildClassName ( 'overlay' , overlayClassName ) }
273
290
style = { { ...overlayStyles , ...this . props . style . overlay } }
274
- onClick = { this . handleOverlayOnClick } >
291
+ onClick = { this . handleOverlayOnClick }
292
+ onMouseDown = { this . handleOverlayOnMouseDown }
293
+ onMouseUp = { this . handleOverlayOnMouseUp } >
275
294
< div
276
295
ref = { this . setContentRef }
277
296
style = { { ...contentStyles , ...this . props . style . content } }
278
297
className = { this . buildClassName ( 'content' , className ) }
279
298
tabIndex = "-1"
280
299
onKeyDown = { this . handleKeyDown }
281
300
onMouseDown = { this . handleContentOnMouseDown }
301
+ onMouseUp = { this . handleContentOnMouseUp }
282
302
onClick = { this . handleContentOnClick }
283
303
role = { this . props . role }
284
304
aria-label = { this . props . contentLabel }
0 commit comments