Skip to content
Merged
Changes from 2 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
15 changes: 15 additions & 0 deletions src/fire-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const select = fireEvent.select
fireEvent.select = (node, init) => {
select(node, init)
// React tracks this event only on focused inputs
// TODO probably need to fire focusin for JSDOM compat
node.focus()

// React creates this event when one of the following native events happens
Expand All @@ -41,4 +42,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}