File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ export class Button extends ButtonBase {
6060
6161 private _mountedButton : HTMLButtonElement | null = null ;
6262 private _lastMouseDownEvent : Types . SyntheticEvent | undefined ;
63+ private _ignoreMouseUp = false ;
6364 private _ignoreClick = false ;
6465 private _longPressTimer : number | undefined ;
6566 private _isMouseOver = false ;
@@ -210,13 +211,21 @@ export class Button extends ButtonBase {
210211 if ( this . props . onLongPress ) {
211212 // lastMouseDownEvent can never be undefined at this point
212213 this . props . onLongPress ( this . _lastMouseDownEvent ! ) ;
214+ this . _ignoreMouseUp = true ;
213215 this . _ignoreClick = true ;
214216 }
215217 } , this . props . delayLongPress || _longPressTime ) ;
216218 }
217219 }
218220
219- private _onMouseUp = ( e : Types . SyntheticEvent ) => {
221+ private _onMouseUp = ( e : Types . SyntheticEvent | Types . TouchEvent ) => {
222+ if ( this . _ignoreMouseUp ) {
223+ e . stopPropagation ( ) ;
224+ // Touch event won't trigger onClick when a long press is released. So we reset the ignore flag here.
225+ if ( 'touches' in e ) {
226+ this . _ignoreClick = false ;
227+ }
228+ }
220229 if ( this . props . onPressOut ) {
221230 this . props . onPressOut ( e ) ;
222231 }
You can’t perform that action at this time.
0 commit comments