Skip to content

fix(ui): a dialog's focus trap no longer pulls Tab back when a tooltip closes on blur - #34091

Merged
objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/project-thread-ozamq5
Nov 15, 2026
Merged

objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/project-thread-ozamq5

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread

Fixes #33980

Clause-②: no
Metadata-protocol: none

Claim by domain:ui#1, card-thread session session_01ADHkmPwoJquHrWGDjT1P4r.

维护者速读

  • 改了什么:给弹窗焦点陷阱(Radix FocusScope)的补丁加一段:只有「上一个获得焦点的元素」真的不在弹窗里了,才把焦点拉回弹窗本身。导入向导里 fix(plugin-grid): Tab leaves the import wizard's Save-current reason again #33960 加的局部绕法(把 tooltip 挪出弹窗)随之撤掉。
  • 为什么改:弹窗里一个带内联 tooltip 的按钮,按 Tab 离开时 tooltip 被卸载,陷阱误判为「焦点元素被删」,把焦点拉回弹窗,键盘用户出不去。除导入向导外,实测「管理视图」对话框也中招:Tab 过不了第一行的 Pin 按钮,其余视图、Done、Close 都到不了。修在陷阱上,所有弹窗一次修好。
  • 风险与回滚:只改补丁里一个判断条件,焦点元素真被删除时仍拉回弹窗(单测对照钉住)。改动面是所有 Dialog / Sheet / AlertDialog 的焦点处理;回滚即 revert(会同时带回导入向导的问题,因为局部绕法已撤)。
  • 先看:patches/@radix-ui__react-focus-scope.patch(新增的 handleMutations 两行),ui/packages/components/src/__tests__/dialog-popover-focus-scope.test.tsx(新 describe),ui/e2e/manage-views-keyboard-tab-order.spec.ts。
  • 两分钟验证:pnpm --dir ui exec playwright test e2e/manage-views-keyboard-tab-order.spec.ts e2e/import-wizard-keyboard-tab-order.spec.ts --project=chromium,预期 6 passed。
  • 需要你做的:无,席位落地。

What changes

  • patches/@radix-ui__react-focus-scope.patch (the file pnpm-workspace.yaml's patchedDependencies applies) gains a second hunk in dist/index.js and dist/index.mjs: the trapped scope's MutationObserver callback returns early when the last focused element is still inside the container. Stock radix focuses the container whenever a node under it is removed while focus sits on body; between the blur and the focus of a native Tab focus does sit on body, so a node that a blur unmounts (an inline tooltip closing under its trigger) pulled focus back to the container. The callback now acts only on the case it exists for: the focused element, or an ancestor of it, was itself removed. The earlier stack-race hunk is unchanged.
  • ui/patches/@radix-ui__react-focus-scope.patch gets the same bytes. It is an unreferenced copy (nothing reads it; pnpm-workspace.yaml names the root file), kept identical rather than left to drift; deleting it is not this card. ui/patches/README.md: the entry now describes both halves, its Tracking/Upstream rows name the second, and Remove-when requires every regression case green with the patch removed.
  • pnpm-lock.yaml: the patch hash for @radix-ui/react-focus-scope@1.1.16 (7 lines, from pnpm install).
  • ui/packages/plugin-grid/src/ImportWizard.tsx: fix(plugin-grid): Tab leaves the import wizard's Save-current reason again #33960's local createPortal of the Save-current reason tooltip is removed (git apply -R of that hunk); the tooltip mounts inline again, and Tab still leaves it (spec below).
  • Changesets: new .changeset/33980-focus-trap-blur-unmount.md (@object-ui/console, @objectstack/console, @object-ui/plugin-grid: patch). DELIBERATE CORRECTION of the pending .changeset/33862-import-wizard-save-reason-tab-trap.md: its last sentence said "The tooltip now renders outside the dialog, so Tab and Shift+Tab walk every control in order…", which this PR makes false; it now reads "The dialog's focus trap no longer reads that removal as focus lost, so Tab and Shift+Tab walk every control in order and the reason is still read out when the wrapper is focused." check-empty-changeset is red on that file by design.

Why A (the focus-scope patch) and not B (portal TooltipContent)

Measured first, on origin/main fb79d47c: which inline-tooltip triggers sit inside a modal dialog. Statically, 35 non-test files under ui/packages name TooltipContent; six of them also render a Dialog / Sheet / AlertDialog (ImportWizard, ManageViewsDialog, MarketplacePackagePage, MarketplaceRowActions, StudioDesignSurface, the Shadcn sidebar). Measured in Chromium with real Tab presses (Vite bundle from src/, no stylesheet):

Site Before (fb79d47) After
Import wizard, Save-current reason (with #33960's portal removed) trapped (the #33960 spec's ablation leg, and below) all 8 stops
Manage Views dialog, each row's Pin / Set-as-default button (ObjectView wires both) trapped: search, drag, All, Pin, dialog, search… all 12 stops
A generic Dialog with a focusable tooltip trigger between two buttons trapped: a, b, dialog, a… a, b, c, Close

Not measured: StudioDesignSurface (a tooltip in an inspector its selection Sheet may hold), tooltips in views a record drawer may host, and DisabledReasonTrigger when metadata places a disabled action inside a modal. A covers them whatever they turn out to be.

Why "no stylesheet" is the production case: the Console's index.css leaves @plugin 'tailwindcss-animate' commented out, so data-[state=closed]:animate-out has no rule and a closing tooltip unmounts at once, inside the blur→focus gap. With an exit animation the unmount waits for animationend and nothing traps (measured on the generic probe: a, b, c, Close) — which is why this hides in some setups.

  • A fixes the trap's heuristic, so every blur-driven unmount under a modal is covered, not only tooltips, in every dialog at once; the repo already patches this exact package and version for another focus race, with a README entry and a removal condition.
  • B was not taken: it closes only the tooltip half (any other node a blur removes still traps); ui/packages/components/src/ui/tooltip.tsx is a Shadcn-synced file (ui/AGENTS.md Remove explicit pnpm version from workflows to fix version conflict #7), tracked from shadcn's default style, which does not portal, so B is a local divergence to declare in ui/scripts/shadcn-local-patches.mjs; and it moves every tooltip in the app out of its subtree into body, a DOM change for every tooltip to fix a defect that only exists under a focus trap.

Tests

  • Unit, ui/packages/components/src/__tests__/dialog-popover-focus-scope.test.tsx (the shared harness of the existing patch; new top-level describe): a trapped scope whose trigger drops a sibling node on blur — after blur() focus is not on the container (red on stock); CONTROL — removing the focused element itself still focuses the container (green either way). A scripted blur() puts focus on body before the observer callback runs, so this unit case can go red in happy-dom, unlike a user-event Tab walk.
  • New e2e, ui/e2e/manage-views-keyboard-tab-order.spec.ts (Build & E2E UI, chromium; the harness of fix(plugin-grid): Tab leaves the import wizard's Save-current reason again #33960's spec): the real ManageViewsDialog bundled from source, native Tab and Shift+Tab over two editable views (12 stops, past both Pins and Set-as-default) and a CONTROL of two read-only views (no tooltip trigger, 7 stops).
  • ui/e2e/import-wizard-keyboard-tab-order.spec.ts: green with the local portal removed. Forced test edit: its header sentence "The reason tooltip is now portalled out of the dialog…" became false and now names the trap patch; no assertion changed.
  • Ablation (fix committed first): the patch's guard line deleted from the installed dist/index.mjs (marker /* ablated */, guard count 1 → 0, blob 4dfa11db5c8c → a97219dd468f).
    • unit: the new case red, the control and the 3 existing cases green;
    • e2e: Manage Views editable case red (…, manage-views-pin-all, dialog, manage-views-search, …), import wizard nothing-mapped and tooltip cases red (…, reason:import-template-save-btn, dialog, …), the 3 controls green.
    • Restore proven both times: blob back to 4dfa11db5c8c, which is the post-image blob the patch itself names for dist/index.mjs; guard count 1. (scripts/ablation-replace.mjs refused to certify the restore of a path git does not track, so the restore was done by hand and proven by hash.)
Local runs (head 279bded)
playwright e2e/manage-views-keyboard-tab-order.spec.ts e2e/import-wizard-keyboard-tab-order.spec.ts --project=chromium
  head 279bded8:              6 passed
  ablation (guard deleted):   3 failed (manage-views editable; import-wizard nothing-mapped; import-wizard tooltip), 3 passed (controls)
vitest packages/components/src/__tests__/dialog-popover-focus-scope.test.tsx
  head:      5 passed
  ablation:  1 failed (a node a blur unmounts...), 4 passed
vitest packages/components/ packages/plugin-grid/ packages/plugin-view/ (lock VERDICT command-exit 0)
  Test Files 827 passed | 1 skipped (828); Tests 7755 passed | 24 skipped (7779)
type-check:e2e, @object-ui/components type-check, @object-ui/plugin-grid type-check (lock VERDICT command-exit 0)
Chromium probes on origin/main fb79d47c (before the patch; Vite bundle from src, no stylesheet):
  generic Dialog + tooltip trigger:  a, b, dialog, a, b
  same, with an exit-animation rule: a, b, c, Close, a
  ManageViewsDialog (2 views):       search, drag-all, All, pin-all, dialog, search, ...
after the patch:
  generic:            a, b, c, Close, a
  ManageViewsDialog:  search, drag-all, All, pin-all, actions-all, drag-mine, Mine, pin-mine, default-mine, actions-mine, done, Close, search

Acceptance notes

  • ui/patches/README.md's header still says patches are "declared in the root package.json"; they are declared in pnpm-workspace.yaml. Doc drift, outside this card's file surface; noted, not fixed.
  • No upstream radix issue is known for the mutation-handler half; the README says so rather than citing one.

Verification

Local, on head 279bded8 (merge base fb79d47c; origin/main 63db7240, none of its 10 commits touches these files): node scripts/pm/dispatch-gates.mjs --commands derived 52; --ran with the exit codes: 52 derived, 51 run, 1 NOT-MEASURED, 0 UNRUN.

  • check-empty-changeset --base origin/main exits 1 by design: the DELIBERATE CORRECTION of .changeset/33862-import-wizard-save-reason-tab-trap.md above, for the seat's record.
  • check:dual-build-cjs-loads: NOT MEASURED locally (exit 3, PREREQUISITE NOT MET: it reads every package's dist/, and only the closures these tests need were built). It is derived from the lockfile line only; CI's Lint & Repo Gates runs it on a full build.
  • Also run: ui check:new-line-citations (0 new); check-governed-merges --branch HEAD: NOT governed, 0 of 10 paths, 477 changed lines.
Derived gates, each exit code
node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
node scripts/check-adr-0087-registration.mjs --self-test :: exit 0
node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-dts-emitted.mjs --self-test :: exit 0
node scripts/check-empty-changeset.mjs --base origin/main :: exit 1
node scripts/check-empty-changeset.mjs --self-test :: exit 0
node scripts/check-osv-exemptions.mjs :: exit 0
node scripts/check-osv-exemptions.mjs --self-test :: exit 0
node scripts/check-sdui-manifest.mjs :: exit 0
node scripts/check-sdui-manifest.mjs --self-test :: exit 0
node scripts/ci/assert-turbo-remote-cache.mjs --self-test :: exit 0
node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0
node scripts/ci/prune-turbo-cache.mjs --self-test :: exit 0
node scripts/ci/snapshot-next.mjs --self-test :: exit 0
node scripts/osv-base-relative.mjs --self-test :: exit 0
node scripts/pm/check-governed-queue-guard.mjs --self-test :: exit 0
node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --dir ui exec vitest run scripts/ :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm --filter @objectstack/spec run check:error-code-provenance :: exit 0
pnpm check:changeset-fixed :: exit 0
pnpm check:changeset-gate-self-tests :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:dispatcher-error-vocabulary :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:dts-closure :: exit 0
pnpm check:dual-build-cjs-loads :: exit 3
pnpm check:engine-double-contract :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:lean-entry-closure :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:override-consistency :: exit 0
pnpm check:published-files :: exit 0
pnpm check:query-options-erasure :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:registry-log-declared :: exit 0
pnpm check:rest-log-spy-declared :: exit 0
pnpm check:skill-identifier-liveness :: exit 0
pnpm check:sourcemap-no-sources-content :: exit 0
pnpm check:test-source-alias :: exit 0
pnpm check:tier-file-adoption :: exit 0
pnpm check:type-check-coverage :: exit 0
pnpm check:type-check-debt :: exit 0
pnpm check:undeclared-dep-imports :: exit 0
pnpm check:vendor-export-contract-resolve :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0

Generated by Claude Code

… a node under it unmounts mid-Tab

FocusScope's mutation handler now refocuses the container only when the
last focused element is no longer inside it.

Claude-Session: https://claude.ai/code/session_01ADHkmPwoJquHrWGDjT1P4r
Co-authored-by: Claude <noreply@anthropic.com>
…rt wizard's local tooltip portal

Claude-Session: https://claude.ai/code/session_01ADHkmPwoJquHrWGDjT1P4r
Co-authored-by: Claude <noreply@anthropic.com>
…ard note it supersedes

Claude-Session: https://claude.ai/code/session_01ADHkmPwoJquHrWGDjT1P4r
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 15, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#1 · os-steve · session_01ADHkmT2NE3iyG1o6TDg3sf

Seat reading of Test Core (7/8) red on head 279bded897b218f7be6206a4fc9700c49309436a (run 43746236229, attempt 1), at 2026-11-15T18:54Z:

  • The only failing task is @objectstack/scenarios#test: 2 of 34 tests in packages/qa/scenarios/test/runner/run-date.test.ts (run on 2028-02-28 and on 2028-03-31), both Error: Test timed out in 5000ms at l.194. No assertion ran to a verdict, so the leg measured nothing; the other 881 tests in the package passed.
  • This PR's diff touches no file under packages/qa/** and nothing that package imports (Radix focus-scope patch, ImportWizard.tsx, two ui/e2e specs, one components test, changesets, lockfile).
  • Judged a load timeout flake. The seat re-runs the failed jobs ONCE through rerun-failed.mjs when the run completes; a second red is treated as real.

Check Changeset red is the DELIBERATE CORRECTION of .changeset/33862-… and is handled by the contract-review record at landing.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#1 · os-steve · session_01ADHkmT2NE3iyG1o6TDg3sf

Contract review

Served-tier: TIER_DEFAULT
Head-sha: bca6ac58cf6ee6f005f41f280fd34ba4945c7576
Local-runs: none

Face: declaration (both changesets carry Clause-②: no; no published schema, no governed path: check-governed-merges --pr 34091 0 of 10 paths). This record is also the same-head confirmation the DELIBERATE CORRECTION class of check-empty-changeset asks for, because the diff changes code. Inputs read: card #33980, the Claim and its amendment, the os-dev report, PR #34091 body, the net diff against main at the merge base (10 files), and the check-runs on this head (2026-11-15T20:27Z: 56 success, 9 skipped, 1 failure = Check Changeset, the designed red below).

① Derived judgments

  • Behaviour: both copies of the Radix focus-scope patch (root patches/ and ui/patches/, byte-identical) add one early return to handleMutations: when focus sits on body and the last element the scope saw focused is still inside the container, a removed node is not read as focus lost. Focus is pulled back to the container only when the last focused element really is gone, which is what the trap exists for. pnpm-lock.yaml moves only the patch hash.
  • Consumer: ImportWizard.tsx drops its local createPortal workaround; the "Save current" reason tooltip renders inline again. The sr-only description span is unchanged, so the reason is still read with the tooltip closed.
  • Public surface: no export moves in @object-ui/plugin-grid, @object-ui/console or @objectstack/console. Metadata-protocol: none is right.
  • Pins: dialog-popover-focus-scope.test.tsx (unit), manage-views-keyboard-tab-order.spec.ts (new e2e) and the updated import-wizard-keyboard-tab-order.spec.ts header; Build & E2E UI and the Test UI shards concluded success on this head.

② Semver level

.changeset/33980-focus-trap-blur-unmount.md: patch on @object-ui/console, @objectstack/console, @object-ui/plugin-grid, Clause-②: no. Correct: a fix with no surface change.

DELIBERATE CORRECTION of the pending note .changeset/33862-import-wizard-save-reason-tab-trap.md (@object-ui/plugin-grid patch, unreleased), judged sentence by sentence. One sentence changes, the last:

  • Before: "The tooltip now renders outside the dialog, so Tab and Shift+Tab walk every control in order and the reason is still read out when the wrapper is focused."
  • After: "The dialog's focus trap no longer reads that removal as focus lost, so Tab and Shift+Tab walk every control in order and the reason is still read out when the wrapper is focused."

The before sentence becomes false in this PR: ImportWizard.tsx no longer portals the tooltip out of the dialog. The after sentence is true of this head: the trap's early return is exactly "no longer reads that removal as focus lost", and the import-wizard e2e still walks every control. The three sentences before it are unchanged and still true (they describe the defect). Restoring the base text would put a false sentence into the release notes, so the red stands. Confirmed.

③ Boundary flags

  • Designed red: Check Changeset (pr-automation.yml, pull_request only, not on merge_group; the gate's source states it is red by design for this class). Lands with that red under the three conditions; the ACCEPT names the gate and the reason.
  • Flake handled: Test Core (7/8) on the prior head (scenarios run-date.test.ts 5000 ms timeouts, no file of this diff in its import closure) was re-run once and passed; this head's run is green.
  • security_findings: none.

Implemented-by: claude/project-thread-ozamq5
Reviewed-by: session_01ADHkmT2NE3iyG1o6TDg3sf

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#1 · os-steve · session_01ADHkmT2NE3iyG1o6TDg3sf

席位核对

Verdict: ACCEPT · head bca6ac58 · 2026-11-15T20:28Z

  1. Shape. Draft → main, Fixes #33980. 10 files on the claimed surface (with the root patches/ copy per claim amendment): the two identical focus-scope patches, pnpm-lock.yaml (patch hash), ImportWizard.tsx (workaround removed), one unit test, two e2e specs, ui/patches/README.md, one new changeset and one corrected pending changeset.
  2. Contract. Clause-②: no, Metadata-protocol: none; same-head TIER_DEFAULT record PASS: comment 6900856166, which also confirms the DELIBERATE CORRECTION of .changeset/33862-import-wizard-save-reason-tab-trap.md sentence by sentence.
  3. Designed red, landing with it. Check Changeset is red by design: check-empty-changeset's DELIBERATE CORRECTION class (a pending note rewritten in the same stroke as the change that made it false). All three conditions hold: the gate's source states the red is by design on the pushed branch; the job runs on pull_request only (pr-automation.yml), never on merge_group; this comment names the gate and the reason.
  4. Gates on bca6ac58. 66 check runs: 56 success, 9 skipped, 1 failure (Check Changeset, above). The prior head's Test Core (7/8) timeout flake was re-run once and passed.
  5. K. K = 3 first-parent commits on main since the merge base; no sync owed (this head is the merge-only relay sync made at K = 15).
  6. Governed. check-governed-merges --pr 34091: NOT governed (0 of 10 paths).
  7. Landing. This stroke: pr_ready + automerge_enable, under the maintainer's landing approval in the seat thread (2026-11-15T16:10Z, 「批准席位 本班复核通过的 PR 执行 --land」). On MERGED Fixes #33980 closes the card; the seat then removes pm:dispatched and the assignee.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 15, 2026 20:29
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit ea6de74 Nov 15, 2026
66 of 67 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-ozamq5 branch November 15, 2026 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants