Skip to content

Commit a5c3bac

Browse files
committed
Merge branch 'fix/fire-focusinout' into test/experimental
2 parents f7e4739 + 3edf063 commit a5c3bac

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/fire-event.js

+15
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const select = fireEvent.select
2828
fireEvent.select = (node, init) => {
2929
select(node, init)
3030
// React tracks this event only on focused inputs
31+
// TODO probably need to fire focusin for JSDOM compat
3132
node.focus()
3233

3334
// React creates this event when one of the following native events happens
@@ -41,4 +42,18 @@ fireEvent.select = (node, init) => {
4142
fireEvent.keyUp(node, init)
4243
}
4344

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

0 commit comments

Comments
 (0)