This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Repository navigation
fix(components): emit no for when the built-in select renders no control (objectui#3991) - #8804
Merged
Merged
Conversation
…ntrol (objectui#3991) `for` may only reference a labelable element (button / input / meter / output / progress / select / textarea). When the built-in `select` branch's option list resolves empty — unconfigured, or a `dependsOn` gate withholding it (objectui#2284) — it returns `BuiltinSelectEmptyState`, a `<div>` carrying the status text and no control at all, and `<FormControl>`'s Slot put the field's id on that `div`. The visible label's `for` therefore named a non-labelable element: inert, invalid HTML. Measured on `origin/main` @ b6d07df, `{ name: 'empty', label: 'Empty', type: 'select', options: [] }`: label for="_r_2_-form-item" -> ownerTag = DIV getByLabelText('Empty') -> throws "…the element associated with this label (<div />) is non-labellable…" No control renders, so the honest output is a label with no `for` and the message beside it. Nothing is lost: there is no focusable control in this state, so neither "clicking the label does nothing" nor "the control has no accessible name" can occur — zero user-facing harm, exactly as the card and six triage passes measured. The cost repaired is the invalid HTML and an author/test-side error that reads like a broken renderer. `rendersBuiltinSelectEmptyState` is the third mirror of `renderFieldComponent`'s resolution, alongside `resolveFieldLabelling` and `resolvesToRegisteredFieldWidget`, for the same reason: producer and consumer must not disagree about which component actually renders. The option set is hoisted to one const so the label and the branch read the identical value. Deliberately NOT extended to the registered-widget path (`field:select` -> `@object-ui/fields`' `OptionsEmptyState`): that is the same fault but a different mechanism — the branch belongs to a component the registry resolves, and a third-party `field:select` may render a real control for an empty list, so suppressing the `for` on a host-side guess would break a widget that had it right. Pinned from both sides. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01611D6ZaRaMmwTNQmSbk8MH
…rt `for` (objectui#3991)
`form-builtin-select-empty-default.test.tsx` asserted
`expect(label).toHaveAttribute('for', box.id)` — the exact association
objectui#3991 removes. The branch renders no control, and `for` may only
reference a labelable element, so a `for` naming that `<div>` was inert HTML.
What objectui#3263 actually needed that case to keep true is the OTHER half:
that the empty state moving from inline JSX to a component did not swallow the
props `<FormControl>`'s Slot hands down. That half is unchanged and still
asserted — the box keeps its `id` and its `aria-describedby`. Only the `for`
expectation is inverted, and the association itself is now pinned from the
other side in `form-builtin-select-empty-label-association.test.tsx`.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01611D6ZaRaMmwTNQmSbk8MH
…ty-state-label-association
os-zhuang
marked this pull request as ready for review
September 9, 2026 10:12
os-zhuang
enabled auto-merge
September 9, 2026 10:12
Contributor
✅ Console Performance Budget
The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it. 📦 Bundle Size Report
Size Limits
|
os-zhuang
deleted the
claude/issue-3991-empty-state-label-association
branch
September 9, 2026 10:44
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #3991
The built-in
selectbranch renders no form control when its option list resolves empty, soits visible label now emits no
for. Arm 1 of the ruling on objectui#3991 comment 5599614790.The defect
formay only reference a labelable element (button,input,meter,output,progress,select,textarea). When a built-in{ type: 'select' }'s option list resolves empty —unconfigured, or a
dependsOngate still withholding it (objectui#2284) — the branch rendersBuiltinSelectEmptyState, which is adivcarrying the status text and no control at all, andFormControl's Radix Slot put the field's id on thatdiv. Re-measured onorigin/main@b6d07df4b(:2198/:2477, then:2210/:2489,then
form.tsx:453— all stale; the real anchors today are the component atform.tsx:3501andthe render site at
:3873):The dependency-gated branch measures identically (a
dependsOnchild whose parent is unset).Impact — author- and test-side, not user-side
Zero user-facing harm, exactly as the card measured and six triage passes upheld. No focusable
control exists anywhere in that state, so neither "clicking the label does nothing" nor "the
control has no accessible name" can occur — the thing a name would name does not exist. What is
actually wrong is inert, invalid HTML plus a Testing Library failure that reads like a broken
renderer when it is a correctly-rendered empty state, and whose own remedy line then points
authors at
aria-label/aria-labelledbyon adiv— i.e. at the two arms the ruling refused.(5596312425, the hold-audit release) frames it that way; that framing is not what the card
measured and not what six passes concluded.
The fix
rendersBuiltinSelectEmptyStateis the third mirror ofrenderFieldComponent's resolution,alongside
resolveFieldLabellingandresolvesToRegisteredFieldWidget, and it is a mirror forthe same reason those two are: producer and consumer must not be able to disagree about which
component actually renders.
BUILTIN_FIELD_TYPES, exactly as there —a bare
selectrenders this branch and the registry is never consulted;down, which is the very value
renderFieldComponent's!options || options.length === 0tests. Hoisted to one
constso the label and the branch cannot read two spellings of it.The suppression reuses the existing channel —
htmlFor: undefinedin the propsFormLabelspreads after its own
htmlFor, the same key objectui#3961 / #4788 / #4857 already use. No newprop is threaded through the form stack.
PM premise check (asked for explicitly, measured before writing anything)
The dispatch premise was "the
foris emitted byFormLabelunconditionally, and the branchthat renders
BuiltinSelectEmptyStateis knowable at the pointFormLabeldecides."forconditionally for group-labelled and host-wrapped display widgets, so the channel exists;
render scope, above the label's JSX.
What this does NOT achieve, stated because it was an acceptance criterion
getByLabelText('Empty')still throws after the fix — now with the truthful "no form controlwas found associated to that label" instead of the misleading "non-labellable" one. That is
inherent, not a shortfall: Testing Library throws for any label whose text matches while it
associates no control, and the only way to make it resolve is to give the empty state an
associable target — an IDREF or a synthetic role. Both were refused on the card, and correctly:
there is no control in this branch, so either would name a thing that is not a control. The
acceptance wording "
getByLabelTextno longer throws" is achievable only under the refusedarms; the ruling wins, and the pins assert the DOM instead.
Tests
New pin
form-builtin-select-empty-label-association.test.tsx(8 cases) asserts the renderedDOM, never the source text:
for, and still reads as the field's name;label[for]points at a non-labelable element;getByLabelTextfailure no longer contains the defect-specificnon-labellablephrase(a negative substring assertion — deliberately not a pin on a third-party library's wording);
render a control, keeps a
forresolving to the labelable trigger;selectstill resolves its label to the trigger (objectui#3976 stays green);field+ colon +selectwidget that renders a real control on an empty listkeeps its
for— the positive pin for why the suppression stops at the registry boundary.form-builtin-select-empty-default.test.tsxassertedexpect(label).toHaveAttribute('for', box.id)— the exact association this card removes. Re-judged rather than deleted: whatobjectui#3263 needed that case to keep true is that the Slot's props still reach the box (its
idandaria-describedby), which is unchanged and still asserted; only theforexpectationis inverted.
Reverse verification (direction predicted first, then measured)
Predicted RED. Removing only the suppression line, with the mutation proven on disk (anchor
count 1 -> 0, blob
00b1869b->59b9e3d2) and restored under atrapverified byte-identicalto
HEAD:The four that stayed green are the no-collateral pins (populated select, controlling sibling,
registered-widget path, message still rendered) — they are not accidentally coupled to the fix.
Gates run locally
pnpm --workspace-concurrency=2 --filter '@object-ui/components^...' buildVERDICT command-exit 0(8 projects)pnpm --filter @object-ui/components type-checkVERDICT command-exit 0pnpm --filter @object-ui/components testVERDICT command-exit 0— 249 files, 2288 tests, all passedcheck:control-bytescheck:vi-mock-specifiers/check:vi-mock-inheritcheck:unreferenced-sourcescheck:governed-queue-guard --test(changed paths)AGENTS.mdas a lit control returning exit 3 on the same command shapeform.tsxwarning count identical to its base revision (70 -> 70), so this diff adds none. The config is not type-aware (noparserOptions.project), so it cannot move a verdict on any untouched file. Repo-widelintis CI's.packages/fieldsis not owed locally and is declared to CI: this package's published surfaceis byte-unchanged (no export moves), and the suppression can only fire for a RAW
selecttype,which none of that package's suites register.
验收备注
noted, not filed:BuiltinSelectEmptyStatestill receives the Slot'sidandaria-describedbyon a role-lessdiv, where both are inert by this repo's own repeatedreasoning (objectui#3990 / [fields] 只读态的 group-labelled 字段:description 的 IDREF 同样没有消费者(#3990 修的是「名」,这条是「描述」) #4005). Removing them is not this card's ruling and giving the box a
role is arm 3, explicitly refused — left exactly as it was. 承接者: whoever takes [fields] 注册 widget 路径的 select 空状态丢掉 host id —— label 的 for 悬空(objectui#3991 实测出的另一半,不同机制) #8803, which
reaches the same surface.
filed as #8803: the registered-widget twin.@object-ui/fields'OptionsEmptyStateon thesingle
field+ colon +selectpath is the same fault by a different mechanism — measured,not assumed: there the
fordangles (owner NONE) rather than naming adiv, becauseSelectField's empty branch drops the pass-through entirely. It is not fixed here because thehost does not own that branch: a third-party
field+ colon +selectmay render a real control for anempty list, and suppressing the
foron a host-side guess would break a widget that had itright. The other three option widgets (
multiselect/radio/checkboxes) are alreadycorrect in this state — they declare
labelling: 'group'and were repaired by objectui#3990 /[fields] 只读态的 group-labelled 字段:description 的 IDREF 同样没有消费者(#3990 修的是「名」,这条是「描述」) #4005; measured a real
field+ colon +radiowith zero options and its label correctly publishes anid and emits no
for.🤖 Generated with Claude Code
https://claude.ai/code/session_01611D6ZaRaMmwTNQmSbk8MH
Generated by Claude Code