Skip to content

Commit

Permalink
fix(fireEvent): Make sure react dispatches focus/blur events (#758)
Browse files Browse the repository at this point in the history
* test: Run CI with experimental React

* stable -> latest

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

* Remove todo
  • Loading branch information
eps1lon authored Aug 5, 2020
1 parent 0405f56 commit 9aac157
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
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}

0 comments on commit 9aac157

Please sign in to comment.