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

fix(fireEvent): Make sure react dispatches focus/blur events #758

Merged
merged 6 commits into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ node_js:
- 14
- node
env:
- REACT_NEXT=false
- REACT_NEXT=true
- REACT_DIST=latest
- REACT_DIST=next
- REACT_DIST=experimental
install:
- npm install
# as requested by the React team :)
# https://reactjs.org/blog/2019/10/22/react-release-channels.html#using-the-next-channel-for-integration-testing
- if [ "$REACT_NEXT" = true ]; then npm install react@next
react-dom@next; fi
- npm install react@$REACT_DIST react-dom@$REACT_DIST
script:
- npm run validate
- npx codecov@3
Expand All @@ -27,7 +27,8 @@ branches:

jobs:
allow_failures:
- env: REACT_NEXT=true
- REACT_DIST=next
- REACT_DIST=experimental
include:
- stage: release
node_js: 14
Expand Down
14 changes: 14 additions & 0 deletions src/fire-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,18 @@ fireEvent.select = (node, init) => {
fireEvent.keyUp(node, init)
}

// React event system tracks native focusout/focusin events for
// running blur/focus handlers
// @link https://github.com/facebook/react/pull/19186
const blur = fireEvent.blur
const focus = fireEvent.focus
fireEvent.blur = (...args) => {
fireEvent.focusOut(...args)
return blur(...args)
}
fireEvent.focus = (...args) => {
fireEvent.focusIn(...args)
return focus(...args)
}

export {fireEvent}