@@ -68,6 +68,8 @@ export default class Dialog extends React.Component<IDialogPropTypes, any> {
68
68
private sentinelEnd : HTMLElement ;
69
69
private bodyIsOverflowing : boolean ;
70
70
private scrollbarWidth : number ;
71
+ private dialogMouseDown : boolean ;
72
+ private timeoutId : number ;
71
73
72
74
componentWillMount ( ) {
73
75
this . inTransition = false ;
@@ -114,6 +116,7 @@ export default class Dialog extends React.Component<IDialogPropTypes, any> {
114
116
if ( this . props . visible || this . inTransition ) {
115
117
this . removeScrollingEffect ( ) ;
116
118
}
119
+ clearTimeout ( this . timeoutId ) ;
117
120
}
118
121
119
122
tryFocus ( ) {
@@ -136,12 +139,25 @@ export default class Dialog extends React.Component<IDialogPropTypes, any> {
136
139
afterClose ( ) ;
137
140
}
138
141
}
142
+
143
+ onDialogMouseDown = ( ) => {
144
+ this . dialogMouseDown = true ;
145
+ }
146
+
147
+ onMaskMouseUp : React . MouseEventHandler < HTMLDivElement > = ( ) => {
148
+ if ( this . dialogMouseDown ) {
149
+ this . timeoutId = setTimeout ( ( ) => {
150
+ this . dialogMouseDown = false ;
151
+ } , 0 ) ;
152
+ }
153
+ }
154
+
139
155
onMaskClick = ( e : React . MouseEvent < HTMLDivElement > ) => {
140
156
// android trigger click on open (fastclick??)
141
157
if ( Date . now ( ) - this . openTime < 300 ) {
142
158
return ;
143
159
}
144
- if ( e . target === e . currentTarget ) {
160
+ if ( e . target === e . currentTarget && ! this . dialogMouseDown ) {
145
161
this . close ( e ) ;
146
162
}
147
163
}
@@ -222,6 +238,7 @@ export default class Dialog extends React.Component<IDialogPropTypes, any> {
222
238
style = { style }
223
239
className = { `${ prefixCls } ${ props . className || '' } ` }
224
240
visible = { props . visible }
241
+ onMouseDown = { this . onDialogMouseDown }
225
242
>
226
243
< div tabIndex = { 0 } ref = { this . saveRef ( 'sentinelStart' ) } style = { sentinelStyle } >
227
244
sentinelStart
@@ -402,7 +419,8 @@ export default class Dialog extends React.Component<IDialogPropTypes, any> {
402
419
onKeyDown = { this . onKeyDown }
403
420
className = { `${ prefixCls } -wrap ${ props . wrapClassName || '' } ` }
404
421
ref = { this . saveRef ( 'wrap' ) }
405
- onClick = { maskClosable ? this . onMaskClick : undefined }
422
+ onClick = { maskClosable ? this . onMaskClick : null }
423
+ onMouseUp = { maskClosable ? this . onMaskMouseUp : null }
406
424
role = "dialog"
407
425
aria-labelledby = { props . title ? this . titleId : null }
408
426
style = { style }
0 commit comments