Skip to content

Commit

Permalink
fix(ripple): not activating when clicked after touch (#932)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthie authored and Matt Goo committed Jun 21, 2019
1 parent 0818061 commit b2f7855
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/ripple/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ export function withRipple<
this.props.onMouseDown && this.props.onMouseDown(e);
if (!this.isTouched) {
this.activateRipple(e);
} else {
this.isTouched = false;
}
};

Expand Down
16 changes: 16 additions & 0 deletions test/unit/ripple/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,22 @@ test('mouseDown event triggers activateRipple', () => {
mockRaf.restore();
});

test('mouseDown sets isTouched to false if isTouched is true', () => {
const mockRaf = createMockRaf();
const mouseDownHandler = coerceForTesting<React.MouseEventHandler>(td.func());
const wrapper = mount<DivProps>(<DivRipple onMouseDown={mouseDownHandler} />);
const foundation = coerceForTesting<RippledComponent>(wrapper.instance())
.foundation;
foundation.activate = td.func<(evt?: Event) => void>();
(wrapper.instance() as any).isTouched = true;
wrapper.simulate('mouseDown');

mockRaf.flush();
td.verify(foundation.activate(td.matchers.isA(Object)), {times: 0});
assert.isFalse((wrapper.instance() as any).isTouched);
mockRaf.restore();
});

test('mouseUp event triggers deactivateRipple', () => {
const mouseUpHandler = coerceForTesting<React.MouseEventHandler>(td.func());
const wrapper = mount<DivProps>(<DivRipple onMouseUp={mouseUpHandler} />);
Expand Down

0 comments on commit b2f7855

Please sign in to comment.