Repository navigation
fix(plugin-grid): Tab leaves the import wizard's Save-current reason again - #33960
Merged
Merged
Conversation
…tip out of the dialog The reason tooltip's content was mounted inside the dialog and unmounted when Tab blurred its focusable wrapper. The dialog's focus trap saw a node removed under it while focus sat between two elements and pulled focus to the dialog, so Tab could never leave the wrapper. The content now renders in a portal on document.body. Pinned in real Chromium (ui/e2e/import-wizard-keyboard-tab-order.spec.ts): native Tab and Shift+Tab walk every stop of the mapping step in DOM order, with the two control files green. Claude-Session: https://claude.ai/code/session_01ADHkmQbwF4p3MGtT3JR5V3 Co-authored-by: Claude <noreply@anthropic.com>
This was referenced Nov 15, 2026
Contributor
Author
|
domain:ui#1 · os-steve · session_01ADHkmT2NE3iyG1o6TDg3sf 席位核对Verdict: ACCEPT · head
|
Contributor
Author
|
domain:ui#1 · os-steve · session_01ADHkmT2NE3iyG1o6TDg3sf 落地Landing approved by the maintainer in the seat thread at 2026-11-15T16:10Z ("批准席位 本班复核通过的 PR 执行 --land"). The ACCEPT head
State change: on MERGED, |
This was referenced Nov 15, 2026
scbdzhwl
pushed a commit
to scbdzhwl/objectstack-analysis
that referenced
this pull request
Nov 16, 2026
…p closes on blur (objectstack-ai#34091) <!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9Sy653R4fA2ArwDP1QvFqq9)_ Fixes objectstack-ai#33980 Clause-②: no Metadata-protocol: none Claim by `domain:ui#1`, card-thread session `session_01ADHkmPwoJquHrWGDjT1P4r`. ## 维护者速读 - 改了什么:给弹窗焦点陷阱(Radix `FocusScope`)的补丁加一段:只有「上一个获得焦点的元素」真的不在弹窗里了,才把焦点拉回弹窗本身。导入向导里 objectstack-ai#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`**: objectstack-ai#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 objectstack-ai#33960's portal removed) | trapped (the objectstack-ai#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 objectstack-ai#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 objectstack-ai#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.) <details><summary>Local runs (head 279bded)</summary> ``` playwright e2e/manage-views-keyboard-tab-order.spec.ts e2e/import-wizard-keyboard-tab-order.spec.ts --project=chromium head 279bded: 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 fb79d47 (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 ``` </details> ## 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. <details><summary>Derived gates, each exit code</summary> ``` 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 ``` </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmPwoJquHrWGDjT1P4r)_ --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Steve · project thread
Fixes #33862
Clause-②: no
Metadata-protocol: none
Claim by
domain:ui#1, card-thread sessionsession_01ADHkmQbwF4p3MGtT3JR5V3.维护者速读
document.body)。原因 span 仍是可聚焦的 tab 停靠点,聚焦时照样弹出原因。ui/packages/plugin-grid/src/ImportWizard.tsx(TemplateBar 的nothingMapped分支),ui/e2e/import-wizard-keyboard-tab-order.spec.ts。pnpm --dir ui exec playwright test e2e/import-wizard-keyboard-tab-order.spec.ts --project=chromium,预期 4 passed;把{createPortal(换回内联渲染,预期「nothing mapped」与 tooltip 两条转红,两条对照仍绿。What changes
ui/packages/plugin-grid/src/ImportWizard.tsx(TemplateBar, thenothingMappedbranch): the reason tooltip'sTooltipContentis rendered throughcreatePortal(…, document.body)instead of inline. The focusable reason span, itsaria-describedby, thesr-onlyreason and the tooltip text are unchanged, so the disabled-control reason stays reachable by keyboard and is still announced with the tooltip closed.Root cause
Focusing the reason span opens its tooltip, and
@object-ui/components'TooltipContentmounts inline, so the content sat inside the dialog. Tab blurs the span, the tooltip closes and its content unmounts. In a native focus move Chromium runs microtasks between the blur and the focus, withdocument.activeElementonbody; the dialog's RadixFocusScope(trapped) has aMutationObserveron its container that reads "a node under me was removed while focus is on body" as "the focused element was removed", and focuses the container. The browser then abandons the move. That is exactly the card's cycle: template select, reason span, dialog container.Measured in Chromium before the fix (a probe observer on the dialog, removed after): the tooltip node was inside the dialog (
tipInsideDialog: true), the one removal on Tab was the tooltip text "Map at least one column to save a template.", and focus ended on the dialog. Next's own reason span draws no tooltip, which is why it never trapped (the card's third control).Other disabled-with-reason controls with the same wrapper
The trap needs both halves: a reason wrapper whose tooltip mounts inline, and a trapped focus scope (a modal Dialog, Sheet or AlertDialog) around it.
tabIndex={0}tooltip wrapper, read statically:DeclaredActionsBar,record-quick-actions,containers.tsx,ObjectValidationsPanel,FlowLedgerSwitch, the inspectors'_sharedandObjectFieldInspector,HomePage, and the wrappers inStudioDesignSurfaceandMarketplacePackagePage(both files hold dialogs, but the wrappers are outside the dialog contents). None sits inside a modal dialog, so none has this trap; that matches the card's QA pass, which reached Archive, Publish, the field inspector rail, the validation body, the Properties group and Reassign….DisabledReasonTrigger(@object-ui/components, the fouraction:*renderers) is the one site whose placement metadata decides: an action with a declareddisabledpredicate rendered inside a modal dialog would meet the same trap. Not measured.Tests
ui/e2e/import-wizard-keyboard-tab-order.spec.ts(runs inBuild & E2E UI, chromium). It bundles the realImportWizardfrom source with Vite (the harness shape ofe2e/dashboard-metric-tile-height.spec.ts), opens it on a CSV throughinitialFile, clicks the dialog title, then presses Chromium's own Tab and Shift+Tab and names the focused stop after each press. Nothing calls.focus().foo,bar): Tab visits the 8 stops in DOM order (template select, Save-current reason span, both mapping selects, Cancel, Back, Next reason span, Close) and loops to the first; Shift+Tab walks them back.title,project(Save current enabled, no wrapper) and CONTROLtitle,foo(only Next's reason span): the same walks, green before and after the fix.user-event's Tab in happy-dom moves focus with a scripted.focus(), so the mutation is observed after focus already sits on the next stop. Measured on the defect: a happy-domuser-eventwalk visited all 8 stops, so a vitest pin of this cannot go red. The spec header says this.scripts/ablation-replace.mjs, anchor{createPortal(hit 1 → 0, replacement rendering the content inline hit 0 → 1, blob8c3f781e0f72→0d5bd53b2bd1): nothing-mapped case and tooltip case red with the card's cycle (import-template-select,reason:import-template-save-btn,dialog, …), both controls green. Restore proven: blob == HEAD,git diff HEADempty.Local runs (head 71c3677)
Acceptance notes
FocusScopereads to the trap as the focused element removed, and every inlineTooltipContentwith a focusable trigger inside a modal dialog is one such node. This PR fixes the card's control only; the class-wide options are in the os-dev report on the card for the seat.webServerserves the console build; this spec mounts its own page at a routed origin and does not read it.Verification
Local, on head
71c3677d:node scripts/pm/dispatch-gates.mjs --commandsderived 38 commands; all 38 ran and exited 0, and--ranwith the exit codes recorded reconciles 38 derived, 38 run, 0 NOT-MEASURED. Also run:pnpm check:changeset-fixed(exit 0) andui'scheck:new-line-citations(0 new). Everything else (the required eleven, includingBuild & E2E UI, which runs the new spec) is CI's.Derived gates, each exit code
Generated by Claude Code