Repository navigation
[checkbox] Fix stale and duplicated control ids - #5457
Merged
Merged
Conversation
commit: |
Bundle size
PerformanceTotal duration: 944.69 ms -0.62 ms(-0.1%) | Renders: 76 (+0) | Paint: 1,453.57 ms -7.46 ms(-0.5%) No significant changes — details Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
atomiks
force-pushed
the
claude/festive-ramanujan-ce1d31
branch
from
August 10, 2026 14:08
8d2df1f to
c304c94
Compare
atomiks
marked this pull request as ready for review
August 12, 2026 04:07
atomiks
requested review from
colmtuite,
flaviendelangle,
jjenzz and
michaldudak
as code owners
August 12, 2026 04:08
atomiks
enabled auto-merge (squash)
August 12, 2026 04:14
1 task done
AlpenWarden
added a commit
to AlpenWarden/deckwarden
that referenced
this pull request
Oct 24, 2026
…our own change, `@types/node` 20 → 22 to match the Node 22 runtime with Dependabot told to leave its majors to the runtime, and `dotenv` replaced by Node 22's `process.loadEnvFile` behind one `loadEnv()` across its 29 entry points (LATER row 293, the owner's call of 2026-10-23); `pnpm audit` 7 → 1, the `zod` high closed on the runtime root; `/sets`' "Main sets only" box leaves its ids to the Field again because Base UI 1.8 changed how a Checkbox registers one (row 266 fired) The bumps (package.json floors as #10 wrote them, two taken one release past it): `@base-ui/react` 1.7.0 → 1.9.0, `better-auth` 1.7.10 → 1.7.12 (#10 had 1.7.11; 1.7.12, published 2026-10-20, hardens ID-token and OAuth-proxy checks this app's Discord/Google redirect flow already satisfies), `drizzle-orm` 0.45.2 → 0.45.4, `lucide-react` 1.33.0 → 1.61.0 (#10 had 1.59.0), `react`/`react-dom` 19.2.8 → 19.3.1, `tailwind-merge` 3.6.0 → 3.7.0, `zod` 4.4.3 → 4.6.7, `@testing-library/dom` 10.4.1 → 10.4.2, `@testing-library/react` 16.3.2 → 16.3.3, `@types/react` 19.2.18 → 19.3.0 and `@types/react-dom` 19.2.4 → 19.3.0 (ranges stay `^19`), `@vitejs/plugin-react` 6.1.0 → 6.1.2, `drizzle-kit` 0.31.10 → 0.31.11, `jsdom` 30.0.1 → 30.1.3, `prettier` 3.9.6 → 3.9.10 (nothing reformats), `shadcn` 4.22.0 → 4.22.1, `tsx` 4.23.12 → 4.23.15. Their own ranges moved `better-call` 1.4.2 → 1.4.4, `@base-ui/utils` 0.3.2 → 0.5.0, `scheduler` 0.27 → 0.28, `use-sync-external-store` 1.6 → 1.7 and jsdom's tree (`whatwg-url` 17.3.0, `tr46` 7, `data-urls` 8, `html-encoding-sniffer` 7, the `@csstools` set); `jose` and `symbol-tree` left the lockfile. `drizzle-kit` keeps its own `tsx` 4.23.12 beside the root's 4.23.15 (no `pnpm dedupe`: it would also re-key the whole eslint peer set). Audit (LATER row 269, re-run by its last trigger): 7 at the pre-flight → 1. `zod` 4.4.3 GHSA-mrhx-c7xc-m3w5 (high, runtime root) closed by the group's 4.6.7, `shadcn`'s copy deduplicated onto it; `body-parser` 2.3.0 → 2.4.0 (GHSA-27r3-jxmh-p828, high, under `shadcn`'s MCP server) and `fast-uri` 3.1.8 → 3.1.9 (four advisories, under `shadcn` and Sentry's never-wired webpack plugin) by deleting their lockfile entries, no `pnpm.overrides`. `braces` left the audit because GitHub withdrew GHSA-vfj7-8cjw-p6xm on 2026-10-23; the one accepted line left is `esbuild` 0.18.20 under `drizzle-kit`'s loader (alert #1, dismissed). `pnpm advisories:watch` on the new tree: [email protected] clean of 72, [email protected] clean of 37 but GHSA-fmh4-wcc4-5jm3, still accepted (row 271). `@types/node` `^20` → `^22` (22.20.5, the newest 22.x). `.github/dependabot.yml` now ignores its `version-update:semver-major`, and `src/lib/github-workflows.test.ts` pins the ignore and that the range's major is ci.yml's and the nightly's `node-version` — a runtime move changes all three together. `dotenv` → `src/lib/load-env.ts`: `loadEnv()` runs `process.loadEnvFile` over `.env.local`, then `.env`, each only if present — dotenv's `config({ path: [".env.local", ".env"], quiet: true })` precedence exactly (the environment wins over both files, `.env.local` over `.env`, a missing file is skipped, so the nightly runs on its secrets alone). It is a call on the line dotenv's call held in all 29 files (17 scripts, 9 ingest scripts, `src/db/migrate.ts`, `src/db/seed.ts`, `drizzle.config.ts`), never `node --env-file`: the flag fills `process.env` before the first import, and `scripts/smoke/guard.ts` reads `BASE_URL` and `SMOKE_ALLOW_REMOTE` at import time so a line in `.env.local` can't move a smoke's target or make the opt-in standing. `guardDatabaseUrl()` still runs on the next line (the wiring test's `LOAD_ENV` is now `loadEnv();`), and the comments in the guard, the database guard, the session minting and the wiring test that named dotenv now name `loadEnv()`. `src/lib/load-env.test.ts` pins the precedence in a temp directory, that the 29 files load through `loadEnv()` once each, that nothing in src, scripts or the root configs imports dotenv, and that package.json lists it nowhere. `dotenv` 17.4.2 stays in the lockfile only as a transitive of `shadcn` and `@sentry/bundler-plugins`; the 95 gitignored scratch scripts in `scripts/.tmp/` were moved to the helper too. Proof it loads the same: Node's `util.parseEnv` and dotenv's `parse` agree key for key on `.env.local` (9) and `.env.example` (8), and every entry point, run under HEAD and under this change with a preload that stops it at its first network attempt, held all nine `.env.local` variables there (the drizzle config's URL set in both; `sentry-probe` finds no DSN in `.env.local` in both). `/sets` (row 266 FIRED): re-running U10a's SSR id probe on both versions found 1.8.0's "Fix stale and duplicated control IDs" (mui/base-ui#5457) moved a Checkbox inside a Field to the Input's rule: an explicit id reaches the server HTML as the Field's generated id and becomes the explicit one only after hydration, so "Main sets only"'s `label[for="sets-main-only"]` named no element until then. The box and its label now leave the id to the Field, which shares its generated id between them in the server HTML on either version; `sets-index-view.test.tsx` pins that from `renderToString` (it fails on the old markup under 1.9.0). An explicit id outside a Field (the four filter boxes) still renders as given, and no case logs a hydration warning. Row 241 re-read: no Drawer note moves focus into a drawer whose `modal` turns on. Checks: `pnpm check` 2,875 tests / 270 files / 5 warnings (baseline 2,866 / 269 / 5 at 9fbc1c1, the parent), proven alone in a scratch worktree at the parent with only this commit's files; `pnpm build` route table identical (83 lines); the local battery against a dev server on the Neon dev branch (`counters:reset` before each third, then the sixteen `smoke:*` and `search:canned`): all green, 718 checks and the 15 canned searches, the six session-minting smokes signing in through better-auth 1.7.12 and better-call 1.4.4; `/sets`' server HTML on that server names the box from its label, and after hydration the label toggles it. LATER rows 241, 266, 269, 270, 271 and 293 dated. Dependabot #10 and #6 are superseded by this commit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Split out of #5448, which is being broken into smaller PRs.
Closes #2691
Checkbox.Rootread the labelable scope's selected control id back out and rendered it as its own id. Removing theidprop was therefore a no-op, a keyed replacement inherited the id of the instance it replaced, and checkboxes sharing a scope with theirCheckboxGroupall rendered that scope's single id. Each checkbox now resolves its own id throughuseLabelableId, the same wayField.ControlandSwitch.Rootdo.The other half is server rendering.
Field.LabelrendershtmlForfrom the scope'scontrolId, which is only the scope's own generated id until a layout effect registers a real one, and layout effects don't run on the server. So in server markup the element the label targets has to carry the scope's generated id. That is why an explicitidnow lands at hydration, and why a checkbox can no longer take a second id derived from its group.Changes
Checkbox.Rootno longer registers its id by hand. It usesuseLabelableId, which drops a stale id when the prop is removed and re-picks one for a replacement instance.CheckboxGrouprender their own ids. AField.Itemopens a scope the checkbox does own, so per-item labels keep working.Field.LabelomitshtmlForwhen its control is aCheckboxGroup. The group is named througharia-labelledby, andforpreviously pointed at one arbitraryaria-hiddeninput inside it.aria-controlsfrom ids its children report, rather than deriving${groupId}-${value}for every entry inallValues. The reference now reaches the exposedrole="checkbox"element instead of thearia-hiddeninput behind it, survives a customidon a child ([checkbox][CheckboxGroup] Checkbox.Rootidnot working in "parent checkbox" use case #2691), and no longer names an entry that has no child rendered.useLabelableIdreleases its registration in the layout phase rather than a passive effect. A replacement control's layout effect ran first and still saw the outgoing control's registration, so the release had to wait for a StrictMode double-invoke to take effect. Without it, a keyed replacement kept the id of the control it replaced, and aField.Rootthat swapped aCheckboxGroupfor another control was left with nohtmlForat all.Notes
An explicit
idnow reaches the DOM at hydration rather than during SSR, which is a deliberate trade. Server markup carries the scope's generated id on both the label and the control, so clicking the label works before hydration.Field.Control,NumberField.Root,Switch.RootandRadio.Rootalready behave this way, so this makesCheckbox.Rootconsistent with them.aria-controlsis absent from server markup, because a parent checkbox cannot control a child that has not mounted. It appears once the children register. Previously it was always present and always pointed at ids that either did not exist yet or belonged to hidden inputs.One known gap:
Field.Labelstill emits itshtmlForin server markup for aField.Rootwrapping aCheckboxGroup, and drops it during hydration. The suppression runs in a layout effect, and the label renders before the group, so the group cannot report it earlier. Base left the same attribute dangling wheneverallValueswas set.Two or more controls in one
Field.Rootstill share that scope's single control id, so their explicitidprops collapse onto whichever registered first. That is pre-existing behaviour ofuseLabelableId(aCheckboxand aSwitchwith distinct ids already collapse onmaster), andField.Itemis the supported way to give each control its own scope. This PR bringsCheckbox.Rootonto that shared path rather than changing it.RadioGrouphas the same duplicate-id problem: two radios in oneField.Rootshare a single input id. It needs the same treatment and is left for a follow-up.