Skip to content

Commit 9aac157

Browse files
authored
fix(fireEvent): Make sure react dispatches focus/blur events (#758)
* test: Run CI with experimental React * stable -> latest * fix(fireEvent): Make sure react dispatches focus/blur events * Remove todo
1 parent 0405f56 commit 9aac157

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

.travis.yml

+6-5
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ node_js:
99
- 14
1010
- node
1111
env:
12-
- REACT_NEXT=false
13-
- REACT_NEXT=true
12+
- REACT_DIST=latest
13+
- REACT_DIST=next
14+
- REACT_DIST=experimental
1415
install:
1516
- npm install
1617
# as requested by the React team :)
1718
# https://reactjs.org/blog/2019/10/22/react-release-channels.html#using-the-next-channel-for-integration-testing
18-
- if [ "$REACT_NEXT" = true ]; then npm install react@next
19-
react-dom@next; fi
19+
- npm install react@$REACT_DIST react-dom@$REACT_DIST
2020
script:
2121
- npm run validate
2222
- npx codecov@3
@@ -27,7 +27,8 @@ branches:
2727

2828
jobs:
2929
allow_failures:
30-
- env: REACT_NEXT=true
30+
- REACT_DIST=next
31+
- REACT_DIST=experimental
3132
include:
3233
- stage: release
3334
node_js: 14

src/fire-event.js

+14
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,18 @@ fireEvent.select = (node, init) => {
4141
fireEvent.keyUp(node, init)
4242
}
4343

44+
// React event system tracks native focusout/focusin events for
45+
// running blur/focus handlers
46+
// @link https://github.com/facebook/react/pull/19186
47+
const blur = fireEvent.blur
48+
const focus = fireEvent.focus
49+
fireEvent.blur = (...args) => {
50+
fireEvent.focusOut(...args)
51+
return blur(...args)
52+
}
53+
fireEvent.focus = (...args) => {
54+
fireEvent.focusIn(...args)
55+
return focus(...args)
56+
}
57+
4458
export {fireEvent}

0 commit comments

Comments
 (0)