This repository was archived by the owner on Jan 14, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -264,6 +264,8 @@ export function withRipple<
264
264
this . props . onMouseDown && this . props . onMouseDown ( e ) ;
265
265
if ( ! this . isTouched ) {
266
266
this . activateRipple ( e ) ;
267
+ } else {
268
+ this . isTouched = false ;
267
269
}
268
270
} ;
269
271
Original file line number Diff line number Diff line change @@ -75,6 +75,22 @@ test('mouseDown event triggers activateRipple', () => {
75
75
mockRaf . restore ( ) ;
76
76
} ) ;
77
77
78
+ test ( 'mouseDown sets isTouched to false if isTouched is true' , ( ) => {
79
+ const mockRaf = createMockRaf ( ) ;
80
+ const mouseDownHandler = coerceForTesting < React . MouseEventHandler > ( td . func ( ) ) ;
81
+ const wrapper = mount < DivProps > ( < DivRipple onMouseDown = { mouseDownHandler } /> ) ;
82
+ const foundation = coerceForTesting < RippledComponent > ( wrapper . instance ( ) )
83
+ . foundation ;
84
+ foundation . activate = td . func < ( evt ?: Event ) => void > ( ) ;
85
+ ( wrapper . instance ( ) as any ) . isTouched = true ;
86
+ wrapper . simulate ( 'mouseDown' ) ;
87
+
88
+ mockRaf . flush ( ) ;
89
+ td . verify ( foundation . activate ( td . matchers . isA ( Object ) ) , { times : 0 } ) ;
90
+ assert . isFalse ( ( wrapper . instance ( ) as any ) . isTouched ) ;
91
+ mockRaf . restore ( ) ;
92
+ } ) ;
93
+
78
94
test ( 'mouseUp event triggers deactivateRipple' , ( ) => {
79
95
const mouseUpHandler = coerceForTesting < React . MouseEventHandler > ( td . func ( ) ) ;
80
96
const wrapper = mount < DivProps > ( < DivRipple onMouseUp = { mouseUpHandler } /> ) ;
You can’t perform that action at this time.
0 commit comments