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

event.button sent by TestUtils.Simulate.click() is undefined by default #12476

Closed
silvenon opened this issue Mar 28, 2018 · 1 comment
Closed

Comments

@silvenon
Copy link

Do you want to request a feature or report a bug?

Report a bug.

What is the current behavior?

By default Simulate.click() sends an event with an undefined event.button.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:

https://codesandbox.io/s/00lm97zrjn

What is the expected behavior?

I think event.button should default to 0 because that means "left click". Some libraries like react-router rely on this. Maybe they should default to 0, not React? remix-run/react-router#1534

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

I'm not sure about earlier versions, but I'm getting this behavior in react-dom@16.2.0.

@gaearon
Copy link
Collaborator

gaearon commented Aug 2, 2018

You can pass extra data to Simulate APIs so I'd say we leave this out.

I'd also recommend dispatching real browser events in tests instead.

@gaearon gaearon closed this as completed Aug 2, 2018
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