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

Not triggering click event the first time when used with material-ui #124

Open
zsxsoft opened this issue Aug 30, 2017 · 2 comments
Open

Comments

@zsxsoft
Copy link

zsxsoft commented Aug 30, 2017

The bug can reproduce with Chrome and Edge, works fine in Firefox. Also, anujs(https://github.com/RubyLouvre/anu, another React-like library) and React works fine.

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3192.0 Safari/537.36

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16251

Example: https://lucifier129.github.io/material-ui/build/#/

In Chrome, I have to double-click a MenuItem to trigger its onClick event with react-lite.
image

I found the source of bug: https://github.com/callemall/material-ui/blob/master/src/internal/TouchRipple.js#L210. I replaced the rippleGroup to <div />, the issue still exists.

      rippleGroup = (
-       <ReactTransitionGroup style={prepareStyles(mergedStyles)}>
-         {ripples}
-       </ReactTransitionGroup>
+       <div />
      );
    }

Then I tried to debug react-lite. The first click didn't trigger click event.

image
qq 20170830112738

So I wrapped dispatchEvent with setTimeout to wait 65ms, now the click triggered normally. Delaying batchUpdate is useless.
image

I think it's maybe any function canceled mouseup event, but there're no function controlled event.
qq 20170830112958

Now I have no clue...

@zsxsoft
Copy link
Author

zsxsoft commented Aug 30, 2017

So fucking exciting.
node_modules/material-ui/internal/TouchRipple.js, L260,

if (hasRipples)

to

if (true)

It will works correctly!!! But damn it, hasRipples is always true when I click on it, wtf happened???????

@Lucifier129
Copy link
Owner

Intersting, haha~

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

No branches or pull requests

2 participants