Repository navigation
fix(ui): a dialog's focus trap no longer pulls Tab back when a tooltip closes on blur - #34091
Conversation
… 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>
|
domain:ui#1 · os-steve · session_01ADHkmT2NE3iyG1o6TDg3sf Seat reading of
|
|
domain:ui#1 · os-steve · session_01ADHkmT2NE3iyG1o6TDg3sf Contract reviewServed-tier: Face: declaration (both changesets carry ① Derived judgments
② Semver level
DELIBERATE CORRECTION of the pending note
The before sentence becomes false in this PR: ③ Boundary flags
Implemented-by: VERDICT: PASS |
|
domain:ui#1 · os-steve · session_01ADHkmT2NE3iyG1o6TDg3sf 席位核对Verdict: ACCEPT · head
|
Requested by Steve · project thread
Fixes #33980
Clause-②: no
Metadata-protocol: none
Claim by
domain:ui#1, card-thread sessionsession_01ADHkmPwoJquHrWGDjT1P4r.维护者速读
FocusScope)的补丁加一段:只有「上一个获得焦点的元素」真的不在弹窗里了,才把焦点拉回弹窗本身。导入向导里 fix(plugin-grid): Tab leaves the import wizard's Save-current reason again #33960 加的局部绕法(把 tooltip 挪出弹窗)随之撤掉。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 filepnpm-workspace.yaml'spatchedDependenciesapplies) gains a second hunk indist/index.jsanddist/index.mjs: the trapped scope'sMutationObservercallback 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 onbody; between the blur and the focus of a native Tab focus does sit onbody, 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.patchgets the same bytes. It is an unreferenced copy (nothing reads it;pnpm-workspace.yamlnames 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, frompnpm install).ui/packages/plugin-grid/src/ImportWizard.tsx: fix(plugin-grid): Tab leaves the import wizard's Save-current reason again #33960's localcreatePortalof the Save-current reason tooltip is removed (git apply -Rof that hunk); the tooltip mounts inline again, and Tab still leaves it (spec below)..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-changesetis red on that file by design.Why A (the focus-scope patch) and not B (portal
TooltipContent)Measured first, on
origin/mainfb79d47c: which inline-tooltip triggers sit inside a modal dialog. Statically, 35 non-test files underui/packagesnameTooltipContent; 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 fromsrc/, no stylesheet):ObjectViewwires both)All, Pin, dialog, search…Not measured:
StudioDesignSurface(a tooltip in an inspector its selection Sheet may hold), tooltips in views a record drawer may host, andDisabledReasonTriggerwhen 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.cssleaves@plugin 'tailwindcss-animate'commented out, sodata-[state=closed]:animate-outhas no rule and a closing tooltip unmounts at once, inside the blur→focus gap. With an exit animation the unmount waits foranimationendand nothing traps (measured on the generic probe: a, b, c, Close) — which is why this hides in some setups.ui/packages/components/src/ui/tooltip.tsxis a Shadcn-synced file (ui/AGENTS.md Remove explicit pnpm version from workflows to fix version conflict #7), tracked from shadcn'sdefaultstyle, which does not portal, so B is a local divergence to declare inui/scripts/shadcn-local-patches.mjs; and it moves every tooltip in the app out of its subtree intobody, a DOM change for every tooltip to fix a defect that only exists under a focus trap.Tests
ui/packages/components/src/__tests__/dialog-popover-focus-scope.test.tsx(the shared harness of the existing patch; new top-leveldescribe): a trapped scope whose trigger drops a sibling node on blur — afterblur()focus is not on the container (red on stock); CONTROL — removing the focused element itself still focuses the container (green either way). A scriptedblur()puts focus onbodybefore the observer callback runs, so this unit case can go red in happy-dom, unlike auser-eventTab walk.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 realManageViewsDialogbundled 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.dist/index.mjs(marker/* ablated */, guard count 1 → 0, blob4dfa11db5c8c→a97219dd468f).…, 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.4dfa11db5c8c, which is the post-image blob the patch itself names fordist/index.mjs; guard count 1. (scripts/ablation-replace.mjsrefused 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)
Acceptance notes
ui/patches/README.md's header still says patches are "declared in the rootpackage.json"; they are declared inpnpm-workspace.yaml. Doc drift, outside this card's file surface; noted, not fixed.Verification
Local, on head
279bded8(merge basefb79d47c;origin/main63db7240, none of its 10 commits touches these files):node scripts/pm/dispatch-gates.mjs --commandsderived 52;--ranwith the exit codes: 52 derived, 51 run, 1 NOT-MEASURED, 0 UNRUN.check-empty-changeset --base origin/mainexits 1 by design: the DELIBERATE CORRECTION of.changeset/33862-import-wizard-save-reason-tab-trap.mdabove, for the seat's record.check:dual-build-cjs-loads: NOT MEASURED locally (exit 3, PREREQUISITE NOT MET: it reads every package'sdist/, 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.uicheck:new-line-citations(0 new);check-governed-merges --branch HEAD: NOT governed, 0 of 10 paths, 477 changed lines.Derived gates, each exit code
Generated by Claude Code