@@ -65,6 +65,7 @@ export default class ModalPortal extends Component {
6565 } ;
6666
6767 this . shouldClose = null ;
68+ this . moveFromContentToOverlay = null ;
6869 }
6970
7071 componentDidMount ( ) {
@@ -216,6 +217,21 @@ export default class ModalPortal extends Component {
216217 }
217218 }
218219 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 ;
219235 }
220236
221237 handleContentOnClick = ( ) => {
@@ -224,6 +240,7 @@ export default class ModalPortal extends Component {
224240
225241 handleContentOnMouseDown = ( ) => {
226242 this . shouldClose = false ;
243+ this . moveFromContentToOverlay = false ;
227244 }
228245
229246 requestClose = event =>
@@ -271,14 +288,17 @@ export default class ModalPortal extends Component {
271288 ref = { this . setOverlayRef }
272289 className = { this . buildClassName ( 'overlay' , overlayClassName ) }
273290 style = { { ...overlayStyles , ...this . props . style . overlay } }
274- onClick = { this . handleOverlayOnClick } >
291+ onClick = { this . handleOverlayOnClick }
292+ onMouseDown = { this . handleOverlayOnMouseDown }
293+ onMouseUp = { this . handleOverlayOnMouseUp } >
275294 < div
276295 ref = { this . setContentRef }
277296 style = { { ...contentStyles , ...this . props . style . content } }
278297 className = { this . buildClassName ( 'content' , className ) }
279298 tabIndex = "-1"
280299 onKeyDown = { this . handleKeyDown }
281300 onMouseDown = { this . handleContentOnMouseDown }
301+ onMouseUp = { this . handleContentOnMouseUp }
282302 onClick = { this . handleContentOnClick }
283303 role = { this . props . role }
284304 aria-label = { this . props . contentLabel }
0 commit comments