Fixes #32968: focus the entity-type trigger before opening its listbox - #32969
Fixes #32968: focus the entity-type trigger before opening its listbox#32969ShaileshParmar11 wants to merge 1 commit into
Conversation
React Aria's listbox is a non-modal popover, and a press on a trigger that does not already hold focus both opens it and dismisses it a frame later via the focus transition that same press produces. That left the four cold-click call sites roughly 160ms to pick an option, with nothing to reopen the listbox afterwards, so a loaded runner that missed the window retried the option click until the test timed out and ejected the PR from the merge queue. Collapse all five entity-type selections into one selectEntityType helper built on the focus-first sequence the site at :635 already used and which passed in the same CI run that failed the other two. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
Code Review ✅ ApprovedFixes a race condition in OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
✅ Playwright Results — workflow succeededValidated commit ✅ 61 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 35m 51s ⏱️ Max setup 3m 19s · max shard execution 6m 49s · max shard-job elapsed before upload 11m 1s · reporting 2s 🌐 140.15 requests/attempt · 1.46 app boots/UI scenario · 0.00% common-shard skew Optimization targets still in progress:
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
Describe your changes:
Fixes #32968
TestLibrary.spec.tshas been ejecting PRs from the merge queue viaplaywright-summary— most recently #32524 (run, shardchromium-07), a PR that touches nothing in this path. Two tests fail on the same line, clicking theTABLEoption in the entity-type dropdown.Root cause. The listbox dismisses itself ~160 ms after it opens, deterministically — no CI load required:
React Aria's listbox is a non-modal popover. A press on a trigger that does not already hold focus both opens it and produces a focus transition, and that transition dismisses it a frame later. The trigger and form nodes are not remounted, so this is not an RJSF re-render; it is also unrelated to the doc panel (forcing every programmatic scroll instant changes nothing, and the teardown is identical with no fields filled).
Measured, 3/3 runs each:
locator.click()on an unfocused triggerfocus()+ assert focused +click()mouse.click()on an unfocused triggerfocus()+EnterSo the four cold-click sites have always had a ~160 ms window. A dev machine wins that race; a loaded 2-core runner does not — and since nothing reopens the listbox,
option.click()retries until the test timeout.The change. Four sites opened the Select on an unfocused trigger (
:156,:375,:876,:1219); a fifth (:635-650) already focused first and passed in the same CI run that failed the other two. All five collapse into oneselectEntityTypehelper built on that working sequence — net +27 / −42.Type of change:
Checklist:
Manual test steps / verification:
Page-side CPU throttling does not reproduce this, because CI's lag is on the driver side. Injecting a delay between the trigger press and the option click reproduces it exactly:
element is not stable+element was detached from the DOM— CI's exact first-attempt textwaiting for getByRole('option', …)With the trigger focused first, the same scenario passes at 400 ms and at 1500 ms of injected lag — 10× the window.
Running the spec at 4 workers against a local stack:
origin/mainunmodifiedshould maintain page on edit and reset to first page on delete, one of the two CI failuresplatform badgesfailure that also fails on unmodifiedorigin/mainand is unrelatedThe two CI-affected tests,
--repeat-each=3 --workers=4on this branch: 6/6 passed.Lint and types: the CI
ui-checkstyleplaywright sequence (organize-imports → eslint --fix → prettier) is clean and idempotent on the changed file, andtsc --project playwright/tsconfig.jsonreports 0 errors in it (165 pre-existing elsewhere in the project, untouched).Note for reviewers — possible product bug
With a human-speed press (60 ms hold) rather than Playwright's instantaneous down/up, the listbox closed at ~0 ms on both the first and second click, 3/3. If that holds for real hardware input, the entity-type dropdown does not open on a normal mouse click and the real fix belongs in the
ui-core-componentsSelect. I did not confirm this by hand and CDP-injected press-and-hold may not match real input, so it is captured as a note in #32968 rather than a claim — but there are 118getByRole('option')call sites across 38 spec files sitting on the same behaviour, so it is worth someone clicking it.🤖 Generated with Claude Code