Repository navigation
fix(components): action:menu, action:group and action:icon render no text for a non-string label instead of crashing - #37323
Conversation
… labels through the shared renderableLabel guard Claude-Session: https://claude.ai/code/session_012MmDsSBHy5paNUz6zke9Re Co-authored-by: Claude <noreply@anthropic.com>
…d action:icon; patch changeset Claude-Session: https://claude.ai/code/session_012MmDsSBHy5paNUz6zke9Re Co-authored-by: Claude <noreply@anthropic.com>
…es, not the host's attribute spread Claude-Session: https://claude.ai/code/session_012MmDsSBHy5paNUz6zke9Re Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012MmDsSBHy5paNUz6zke9Re Co-authored-by: Claude <noreply@anthropic.com>
…u and action:icon harness files Claude-Session: https://claude.ai/code/session_012MmDsSBHy5paNUz6zke9Re Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#6 · os-lizheng · session_012MmDsSBHy5paNUz6zke9Re 席位核对ACCEPT · 2026-11-25T17:10Z · head
|
|
repo:objectstack#6 · os-lizheng · session_012MmDsSBHy5paNUz6zke9Re Landing (2026-11-25T17:11Z): head
State: |
Fixes #37266
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
ui/packages/components/src/renderers/action/:renderable-label.ts: therenderableLabelguard moved out ofaction-button.tsxunchanged in behaviour. It gains acomponentTypeparameter (defaultaction:button, so the button's warning text is byte-identical) and keys its warn-once memo oncomponentType:componentKey.withRenderableLabel(subject, key, type)returns the same object when the label is a string or absent, otherwise a copy withlabel: undefined. It is one guard, reused, not forked.action-button.tsx: imports the guard; no other change.action-menu.tsx,action-group.tsx,action-icon.tsx: each renderer guards its ownschemaonce at entry (withRenderableLabel, keyed on the component iddata-obj-id), andaction:menu/action:groupguard each member whereactionsis built (keyed on the membername, elseCOMPONENT_ID#INDEX). Every later read then sees a guarded label. The value is never translated (ruling A, 7118756694).static-params.ts: the node-level-params warning names a nameless action throughrenderableLabel(scope note 7163349912).Ruling: option A on #36717 (7118756694), inherited, verbatim: "The renderer must never throw on a non-string label: render no text (or the component id) and log a development warning; it must NOT translate the map (that would accept a value the contract refuses)."
packages/specis untouched.Every label read and its disposition
The seat's re-check,
git grep -n "schema.label\|action.label" -- ui/packages/components/src/renderers/action/, onorigin/maind88c41e: 26 non-test hits.renderableLabel(schema.label, …),label === schema.labeluseMemberVisiblediagnosticaction.labelwithRenderableLabelaction.label && 'mr-2'{action.label}action.label || action.namenamevisiblediagnosticschema.labelwithRenderableLabellabel: action.labelschema.label || 'Actions'Actionsvisiblediagnosticschema.labelwithRenderableLabellabel: schema.labelaria-label={schema.label || schema.name}nameschema.label?.charAt(0) || '?'?(threw on main)schema.label || schema.descriptionschema.label || schema.description(two hits)useAutoTriggerOnce(schema, …),readStaticParamValues(schema, …)(not grep hits)useMenuActionVisiblediagnosticaction.labelwithRenderableLabelaction.label || action.namename(threw on main)visiblediagnosticschema.labelwithRenderableLabellabel: action.labelaria-label={schema.label || moreActionsLabel}More actions{schema.label && ...}(two hits)ActionAutoTrigger→useAutoTriggerOnce(action, …)(not a grep hit)action.name ?? action.label,action.label || action.name(three hits)String(subject.name ?? subject.label ?? '(unnamed)')(not a grep hit)Tests
The pins live in the existing harness files, each as its own top-level
describenaming objectstack#37266 (AGENTS.md, ruling record 6583487846). Each mounts the node through the realSchemaRendererandActionProvider:__tests__/action-group-menu-inputs-11168.test.tsx,describe('action:group — a non-string label renders no text and never throws (objectstack#37266)'): inline (member button has no text and runs with no label, one warning) and dropdown (trigger showsActions, member showsapprove). CONTROL: string labels in both modes.describe('action:menu — a non-string label renders no text and never throws (objectstack#37266)'): a locale-map label on the menu and on a member. No throw, the trigger keepsMore actionsand has no text, the item showsapprove, no[object Object]and neither locale string in the text, the runner gets no label, and there is one warning per component (menu and member). CONTROL: string labels render and reach the runner.__tests__/action-icon-autotrigger.test.tsx,describe('action:icon — a non-string label renders no text and never throws (objectstack#37266)'): noicon(shows?, namedapprove, runs with no label, one warning), withicon(aria-labelisapprove), and a nameless action with node-level objectparams(the static-params warning names(unnamed)and no warning carries[object Object]). CONTROL: a string label is the initial, the accessible name and the runner label.Fitting the harnesses: the group and menu pins use that file's own
mount(which addsSchemaRendererProviderandPredicateScopeProvideraround the node),openMenuandrun; theirconsole.warnspy is set up inside eachdescribe. The icon file drivesaction:iconas anaction:barmember with anapihandler, so the icondescribekeeps its ownrunhandler,SchemaRenderermount,console.warnspy and static-params reset inside thedescribe. The file gained the imports for those. No assertion changed (50expect(calls before and after).Acceptance notes
innerHTML. Both renderers spread the host's undeclared node keys onto the DOM, soactions="[object Object]"is an attribute on any menu or inline group on main, and a rawlabelattribute rides along. That is an attribute leak, not a label read, and it is not user-visible text. It is out of this guard's reach and not filed.paramsnow gets two development warnings: the non-string-label warning (keyed(unnamed)for that renderer type) and the existing params warning. Both are dev-only.action:iconwith a non-string label and noiconshows?, the renderer's existing no-label fallback.action:button, a numeric label is now dropped with the same warning; the contract (z.string()) already refuses it.Verification
Two-minute check:
pnpm --dir ui exec vitest run packages/components/src/renderers/action/__tests__/action-group-menu-inputs-11168.test.tsx packages/components/src/renderers/action/__tests__/action-icon-autotrigger.test.tsx -t "objectstack#37266". Expected: 9 tests passed, the rest skipped.Ablation (shared guard reverted, head 97ac493)
node scripts/ablation-replace.mjsreplaced the guard's string check inrenderable-label.ts(if (label == null || typeof label === 'string') return label ?? undefined;) withreturn label as string | undefined;, then ran the two harness files. The anchor went from 1 hit to 0 and the blob from 0e979351f9ca to fa737ebae282. Result: 2 files failed, 6 tests failed and 37 passed. The 6 failures are the six non-CONTROL label pins; the 37 that passed are the three CONTROLs and every existing test in the two files. The menu test rendered the error boundary'sRetryinstead of the menu (the throw). Three icon tests failed withTypeError: schema.label?.charAt is not a function. The group tests failed on text content and the runner call. After the restore, the blob equals HEAD (0e979351f9ca) andgit diff HEADis empty.Suites and gates (head 97ac493)
pnpm --filter @object-ui/components type-check && pnpm --dir ui exec vitest run packages/components/src/renderers/action/: type-check clean, 37 files and 628 tests passed (VERDICT command-exit 0).pnpm check:test-source-alias,pnpm check:cross-package-test-inputsandpnpm check:nul-byteseach exited 0.dispatch-gates --commandsderived 38 families, all 38 were run and each exit code was captured before any pipe.--ranreconciliation gave 38 derived, 38 run, 0 NOT-MEASURED, and every recorded exit was 0.pnpm check:type-check-debtfirst exited 3, a prerequisite refusal whose cause the loop did not keep, and exited 0 on a standalone re-run.pnpm --dir ui exec vitest run scripts/: 172 files passed and 2 skipped; 5130 tests passed.packages/componentssuite and the CI-only lanes (Lint UI, Test UI shards, Build & E2E UI); CI runs them.Generated by Claude Code
🤖 Generated with Claude Code
https://claude.ai/code/session_012MmDsSBHy5paNUz6zke9Re