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

ReactTestUtils.Simulate no longer works as expected in v15.4.0 #8305

Closed
hunthunthunt opened this issue Nov 16, 2016 · 7 comments
Closed

ReactTestUtils.Simulate no longer works as expected in v15.4.0 #8305

hunthunthunt opened this issue Nov 16, 2016 · 7 comments

Comments

@hunthunthunt
Copy link

Firstly, congrats on the release :)

With the v15.4.0 update, a couple of our projects tests are failing given the changes to ReactTestUtils.Simulate as discussed here:
#7642 (comment)

The work-around was to use ReactTestUtils.SimulateNative - however it's still not entirely clear what the difference between Simulate and SimulateNative are? When and why should one be used over the other?

It feels like these docs should be updated to reflect this change:
https://facebook.github.io/react/docs/test-utils.html#simulate

Finally, is there a reason that SimulateNative does not appear in the docs? I'm concerned that others are going to be caught out by this change also.

@gaearon
Copy link
Collaborator

gaearon commented Nov 16, 2016

cc @spicyj

@grzegorzjudas
Copy link

This is here for 5 months. Is there any reason why firing simulate() on a disabled input/button actually fires the event?

Came here from enzyme repo issue (enzymejs/enzyme#386) and it turns out our shallow() rendered components still call onClick even if disabled attribute is there.

@gaearon
Copy link
Collaborator

gaearon commented Apr 20, 2017

There are many issues that are “here for 5 months”. It’s a popular repository, and the team is very small. This is a low priority issue because it’s not actively breaking apps.

If you have specific suggestions about how to fix this, please propose them! Read the past discussions, research the motivation behind previous changes, and present a proposal of how we should handle this instead. Maybe even send a PR 😉 . You are in the best position to do this because you are actively invested in solving this, and you actually have the context to know how it affects apps.

@grzegorzjudas
Copy link

What I more had in mind, is to just have a clarification whether the problem is actually a bug or is it intended (I can imagine scenarios when you want to have mouse event firing on a disabled input element) - I did not expect the fix to be released immediately.

In short - I wanted an answer, not immediate fix because it's "here for 5 months".

@gaearon
Copy link
Collaborator

gaearon commented Apr 21, 2017

Let’s ask @nhunzaker for context on this.

@aweary
Copy link
Contributor

aweary commented Apr 21, 2017

For reference, there were additional changes made to that code path in #8387

@nhunzaker
Copy link
Contributor

Sorry for the delay...

This was intentional, we did it when we moved the disabled click event behavior from an, at the time, wrapper around Buttons to the SimpleEventPlugin:

#7642

The trade-off was that it would allow Simulate to trigger a click event on disabled buttons. This is because (please correct me if I'm wrong) Simulate bypasses the event plugin system.

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

5 participants