Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ripple triggers twice on mobile #646

Merged

Conversation

aluminick
Copy link
Contributor

No description provided.

@@ -242,6 +242,7 @@ export function withRipple <
};

handleTouchEnd = (e: React.TouchEvent<Surface>) => {
e.preventDefault();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

facebook/react#9809 (comment)
touchEnd event causes mouseDown to fire which causes the double ripple on mobile

@codecov-io
Copy link

codecov-io commented Jan 30, 2019

Codecov Report

Merging #646 into rc0.10.0 will decrease coverage by 0.13%.
The diff coverage is 83.33%.

Impacted file tree graph

@@             Coverage Diff              @@
##           rc0.10.0     #646      +/-   ##
============================================
- Coverage      94.9%   94.77%   -0.14%     
============================================
  Files            68       68              
  Lines          2847     2833      -14     
  Branches        428      427       -1     
============================================
- Hits           2702     2685      -17     
- Misses           50       51       +1     
- Partials         95       97       +2
Impacted Files Coverage Δ
packages/ripple/index.tsx 85.47% <83.33%> (-2.36%) ⬇️
packages/chips/Chip.tsx 97.77% <0%> (-0.21%) ⬇️
packages/chips/ChipSet.tsx 98.64% <0%> (-0.12%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a376474...57b55b1. Read the comment docs.

@@ -273,7 +274,7 @@ export function withRipple <
return;
}
this.setState((prevState) => {
const updatedStyle = Object.assign({}, this.state.style) as React.CSSProperties;
const updatedStyle = Object.assign({}, this.state.style, prevState.style) as React.CSSProperties;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without requestAnimationFrame wrapping this.foundation.activate(e) previous style is not merged. Adding prevState.style to updatedStyle fixes this.

Copy link
Contributor

@moog16 moog16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing! This looks fine and it looks like unit tests are passing, however could you remove the rAF from the units tests for the ripple?

ALSO

I ran the screenshot tests and clicked on the anchor tag button. It does not go to a different link like i rc0.10.0. Could you please address that?

@aluminick
Copy link
Contributor Author

aluminick commented Feb 5, 2019

The anchor tag button is not working because of the preventDefault inside onTouchEnd. I added it because for some reason, it triggers the onMouseDown. So the workaround I used is what you told me to check if one of them is activated then don't trigger the other one.

Removing the RAF on all test cases works fine except, the checking of component if it has the mdc-ripple-upgraded class. Maybe because it's async. Wrapping the assertion with setTimeout or setImmediate fixes this. However i'm not sure is this is the right solution.

@moog16
Copy link
Contributor

moog16 commented Feb 6, 2019

@aluminick we shouldn't use setTimeout when there isn't one in the code. I think we actually need a rAF since there is an rAF in MDC Web's activate_ method. Sorry for making you do extra work - lets just leave the rAFs for now.

@moog16
Copy link
Contributor

moog16 commented Feb 6, 2019

@aluminick changes look awesome! Please fix npm run lint and we should be good to go pending the screenshots pass.

@aluminick
Copy link
Contributor Author

@moog16 no worries. I enjoy debugging.

@moog16
Copy link
Contributor

moog16 commented Feb 6, 2019

tests: #659

@moog16
Copy link
Contributor

moog16 commented Feb 6, 2019

@aluminick please sign PR

@aluminick
Copy link
Contributor Author

I signed it

@moog16 moog16 merged commit d141be1 into material-components:rc0.10.0 Feb 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants