Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

fireEvent.select does not wrap its automatic native focus in act

Open Beginner friendly
#1,471 0 comments 0 reactions 0 assignees View on GitHub

@sergioperezcheco is already working on this.

Since Oct 7, 2026.

  • #1472 by @sergioperezcheco — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript, react
Domain
testing

Research direction

Start in src/fire-event.js at fireEvent.select, where the native node.focus() call sits outside the configured eventWrapper used by the surrounding select/keyup dispatches. Read how eventWrapper is configured (see the act wrapping introduced in #685) and wrap that same native focus call, without synthesizing focus events or reordering them. Done means the issue's repro passes — data-focused and data-blurred attributes flush before fireEvent.select returns and no outside-act warning — with the existing src/__tests__ suite green; add a regression test alongside the select tests.

Written by the indexing model from the issue text.

Description

This report was prepared with autonomous AI-agent assistance; it has not received human review.

On current main with React 18.3.1, fireEvent.select focuses an unfocused input or textarea, but React state updates in its onFocus and the previous element's onBlur are not flushed before the call returns. React also reports updates outside act.

import * as React from 'react'
import {render, screen, fireEvent} from '@testing-library/react'

function Example() {
  const [focused, setFocused] = React.useState(false)
  const [blurred, setBlurred] = React.useState(false)
  return <>
    <input aria-label="previous" onBlur={() => setBlurred(true)} />
    <input aria-label="selection" onFocus={() => setFocused(true)}
      data-focused={focused} data-blurred={blurred} />
  </>
}
render(<Example />)
screen.getByRole('textbox', {name: 'previous'}).focus()
const input = screen.getByRole('textbox', {name: 'selection'})
fireEvent.select(input)
expect(document.activeElement).toBe(input) // passes
expect(input.getAttribute('data-focused')).toBe('true') // receives false
expect(input.getAttribute('data-blurred')).toBe('true')

The existing native node.focus() call in src/fire-event.js is outside the configured eventWrapper, unlike the surrounding select and keyup dispatches. Wrapping that same native focus call fixes the focus/blur updates without synthesizing focus events or changing their order.

Verified against rebuilt original and fixed public dist/pure exports on macOS, Node 18.20.8/24.21.0, React 18.3.1 and jsdom 20.0.3. Formal regressions fail twice on original production with two passing controls. The existing worker_threads MessageChannel test shim keeps raw Jest alive after tests in this environment; an evidence-only native Node setImmediate bridge permits natural exit. No forced exit or repository configuration change is part of the fix.

Related: #685 established automatic act wrapping; #1214 proposes a broader asynchronous fireEvent API, and #1429 changes event argument forwarding. Neither wraps select's native focus call.

Dominant language
JavaScript
Stars
19.7k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from testing-library/react-testing-library

All issues in testing-library/react-testing-library

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.