Skip to content

Implement focusin/focusout events. #182

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

Merged
merged 2 commits into from
Dec 16, 2018

Conversation

sarenji
Copy link
Contributor

@sarenji sarenji commented Dec 16, 2018

What:

Adds the focusin and focusout events. Fixes #179.

Sorry this PR took so long, I needed some personal time and wanted to make sure I was informed. The focusin/focusout events are described in two documents:

Why:

I added document.addEventListener('focusin', handler); to some of my React components. In dom-testing-library, we can only trigger this handler by dropping down to the low-level fireEvent(element, event) API. For consistency, it'd be nice to provide a focusin/focusout convenience API like the other events.

How:

  1. Changed tests to account for focusin/focusout.
  2. Added the two events to events.js, and making sure they bubble.

Checklist:

  • Documentation (N/A: The docs just link to the events.js file.)
  • Tests
  • Ready to be merged
  • Added myself to contributors table

This is part of a bigger story around lack of focusin/focusout implementation: jsdom does not fire focusin/focusout events when focusing or blurring. And React does not expose focusin/focusout either.

Great library, BTW! Let me know if there's anything else I need to do. Thank you!

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Perfect! Thanks!

@kentcdodds kentcdodds merged commit 5f7376f into testing-library:master Dec 16, 2018
@kentcdodds
Copy link
Member

🎉 This PR is included in version 3.16.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

focusIn, focusOut, and resize events
2 participants