fireEvent.select does not wrap its automatic native focus in act
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 88/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript, react
- 領域
- testing
調査の方向性
src/fire-event.js の fireEvent.select から読み始めること。ここでは、周囲の select/keyup ディスパッチが使用する設定済みの eventWrapper の外側に、ネイティブの node.focus() 呼び出しがある。eventWrapper がどのように設定されているかを確認し(#685 で導入された act のラッピングを参照)、同じネイティブな focus 呼び出しを、focus イベントを合成したり並べ替えたりせずにラップする。完了の条件は、イシューの再現が通ること — data-focused と data-blurred 属性が fireEvent.select が返る前にフラッシュされ、outside-act の警告が出ない — こと、および既存の src/__tests__ スイートが緑であること。select のテストの隣にリグレッションテストを追加すること。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- JavaScript
- スター
- 19.7k
- フォーク
- 1.2k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
testing-library/react-testing-library のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
testing-library/react-testing-library#1466 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
testing-library/react-testing-library#1459 · コメント 2 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 35/100
testing-library/react-testing-library#1430 · コメント 1 件 ·
-
`fireEvent.mouseEnter` does not forward `relatedTarget` (relatedTarget is the window instead)対応中かも @swarnim02 が 313 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
testing-library/react-testing-library#1421 · コメント 1 件 ·
testing-library/react-testing-library の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 3 日以内に返信
-
audit.md numbers Theming and Responsive Design differently in the headings and the score table対応中かも @pbakaus が今日担当しました。 オープンneeds triage
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
pbakaus/impeccable#979 ·
メンテナーはふだん 1 日以内に返信
-
area/web interface
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
mastodon/mastodon#40924 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug user-priority/P2
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1時間未満 初心者へのやさしさ 78/100
opencart/opencart#15763 · コメント 2 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信