@@ -65,6 +65,7 @@ type ActivateEventTypes<S>
65
65
export interface RippledComponentInterface < Surface , Activator = Element > {
66
66
foundation ?: MDCRippleFoundation ;
67
67
isComponentMounted : boolean ;
68
+ isTouched : boolean ;
68
69
initializeFoundation : ( surface : Surface , activator ?: Activator ) => void ;
69
70
handleFocus : React . FocusEventHandler < Surface > ;
70
71
handleBlur : React . FocusEventHandler < Surface > ;
@@ -101,6 +102,7 @@ export function withRipple <
101
102
> implements RippledComponentInterface < Surface , Activator > {
102
103
foundation ?: MDCRippleFoundation ;
103
104
isComponentMounted : boolean = true ;
105
+ isTouched : boolean = false ;
104
106
105
107
displayName = `WithRipple(${ getDisplayName < P > ( WrappedComponent ) } )` ;
106
108
@@ -228,7 +230,9 @@ export function withRipple <
228
230
229
231
handleMouseDown = ( e : React . MouseEvent < Surface > ) => {
230
232
this . props . onMouseDown && this . props . onMouseDown ( e ) ;
231
- this . activateRipple ( e ) ;
233
+ if ( ! this . isTouched ) {
234
+ this . activateRipple ( e ) ;
235
+ }
232
236
} ;
233
237
234
238
handleMouseUp = ( e : React . MouseEvent < Surface > ) => {
@@ -237,6 +241,7 @@ export function withRipple <
237
241
} ;
238
242
239
243
handleTouchStart = ( e : React . TouchEvent < Surface > ) => {
244
+ this . isTouched = true ;
240
245
this . props . onTouchStart && this . props . onTouchStart ( e ) ;
241
246
this . activateRipple ( e ) ;
242
247
} ;
@@ -259,9 +264,7 @@ export function withRipple <
259
264
activateRipple = ( e : ActivateEventTypes < Surface > ) => {
260
265
// https://reactjs.org/docs/events.html#event-pooling
261
266
e . persist ( ) ;
262
- requestAnimationFrame ( ( ) => {
263
- this . foundation . activate ( e ) ;
264
- } ) ;
267
+ this . foundation . activate ( e ) ;
265
268
} ;
266
269
267
270
deactivateRipple = ( e : ActivateEventTypes < Surface > ) => {
@@ -273,7 +276,7 @@ export function withRipple <
273
276
return ;
274
277
}
275
278
this . setState ( ( prevState ) => {
276
- const updatedStyle = Object . assign ( { } , this . state . style ) as React . CSSProperties ;
279
+ const updatedStyle = Object . assign ( { } , this . state . style , prevState . style ) as React . CSSProperties ;
277
280
updatedStyle [ varName ] = value ;
278
281
return Object . assign ( prevState , {
279
282
style : updatedStyle ,
0 commit comments