Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit b2f7855

Browse files
ArthieMatt Goo
authored andcommitted
fix(ripple): not activating when clicked after touch (#932)
1 parent 0818061 commit b2f7855

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

packages/ripple/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ export function withRipple<
264264
this.props.onMouseDown && this.props.onMouseDown(e);
265265
if (!this.isTouched) {
266266
this.activateRipple(e);
267+
} else {
268+
this.isTouched = false;
267269
}
268270
};
269271

test/unit/ripple/index.test.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,22 @@ test('mouseDown event triggers activateRipple', () => {
7575
mockRaf.restore();
7676
});
7777

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+
7894
test('mouseUp event triggers deactivateRipple', () => {
7995
const mouseUpHandler = coerceForTesting<React.MouseEventHandler>(td.func());
8096
const wrapper = mount<DivProps>(<DivRipple onMouseUp={mouseUpHandler} />);

0 commit comments

Comments
 (0)