Skip to content

onBlur not firing on valid input #543

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

Closed
chrisdhanaraj opened this issue Dec 5, 2019 · 5 comments
Closed

onBlur not firing on valid input #543

chrisdhanaraj opened this issue Dec 5, 2019 · 5 comments

Comments

@chrisdhanaraj
Copy link

Hello! I've ran into an issue where onBlur handler's are not being fired properly when I try to interact with them using fireEvent and normal actions (like click and tab). If I use fireEvent.focus and fireEvent.blur it works fine, but I'd really prefer testing with the standard events.

I saw what looked like a related issue in #359 but that revolved around the input not having type="text, which I've covered in my use case.

  • react-testing-library version: 9.1.4
  • react version: 16.9

I've created a minimal reproduction case here

https://codesandbox.io/s/onblur-not-working-yv1dv

@eps1lon
Copy link
Member

eps1lon commented Dec 6, 2019

Could you clarify why the onBlur handler should be called in the second test case when the element isn't blurred?

@msurekci
Copy link

Could it be related to this? #376 (comment)

@kentcdodds
Copy link
Member

Yes @msurekci, I believe that's exactly the problem.

I'm afraid there's nothing we can do here. You'll need to fire the blur event manually.

@chrisdhanaraj
Copy link
Author

Ah makes sense! @kentcdodds Do you think this would be a candidate to get added to the FAQ or potentially the actions documentation page?

@kentcdodds
Copy link
Member

Yes. If you would like to make a pull request to add it I would be grateful!

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

4 participants