This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Repository navigation
Commit ccddd11
fix(plugin-form): a create form preselects the option a field marks default: true (objectui#11914) (#11944)
Fixes #11914
Clause-②: no
## What changes
A create form preselects the option a field's option list marks
`default: true`, when the field declares no `defaultValue`. This is the
rule the server's insert path applies when a create omits the field. The
objectstack tutorial's Create Ticket form now opens with Priority = Low
and Status = Open, and submits without a manual pick.
**Where.** The fix is in `packages/plugin-form/src/schemaDefaults.ts`,
in `schemaDefaultValues`. That is the one function every object-form
container seeds a create form through (`ObjectForm` directly;
`ModalForm`, `DrawerForm`, `TabbedForm`, `SplitForm` and `WizardForm`
through `seedCreateValues`). A new module-private `optionListDefault`
reads the option list. No second derivation was added in the select
widget.
## Measured first, on `main` `f1781be3a` (H0)
The new pin was run against the unchanged source. It rendered the
console's create dialog (the global `ModalForm`) on the tutorial's
ticket object, verbatim. 11 of 17 tests failed. The main failure:
`AssertionError: expected 'Select an option' to contain 'Low'`. On
`main`, `schemaDefaultValues` returns `{}` for that object, so the
premise holds on current `main`. The module docblock said it
deliberately ignored the option flag "because the server reads
`defaultValue` alone". That stopped being true when the engine began
falling back to the marked option (objectstack#7246).
Bound: H0 rendered the real `ModalForm`, `ObjectForm` and field widgets
with React Testing Library. It did not drive a booted console in a
browser against a live backend.
## The rule: the engine's, read client-side (H1, H2, H3)
This is a read-only check of objectstack `ObjectQL.applyFieldDefaults` /
`resolveOptionDefault` and its test
`engine-select-option-default.test.ts`. The client applies the same
rule:
| Declared | Server stores on omit | Create form now opens with |
|---|---|---|
| option `default: true`, no `defaultValue` | the marked option | the
marked option |
| static `defaultValue` + option flag | `defaultValue` | `defaultValue`
(unchanged) |
| runtime `defaultValue` (`NOW()`, `current_user`, CEL) + option flag |
the resolved token | empty, key omitted (unchanged; the flag is NOT
seeded in its place) |
| `defaultValue: null` + option flag | the marked option (`== null`
presence test) | the marked option |
| several marked, single-valued | the first | the first |
| marked on a multi-valued field (`isMultiValueField`: `multiselect`, or
`select` + `multiple`) | every marked option, as an array | every marked
option, as an array |
| `multiple: true` on a type outside the multi sets | a scalar | a
scalar |
| option value spelled `current_user` | that literal | that literal |
| marked option with no value | nothing | nothing |
The client asks `@objectstack/spec`'s `isMultiValueField` for the arity,
which is the engine's own predicate. It never reads `multiple` raw. Only
the canonical `default` key is read: the spec's alias layer normalizes
`isDefault` / `selected` before metadata is served.
What does not change:
- A caller seed (`initialData` / `initialValues`) and the user's own
pick still win.
- Edit forms are never seeded: they show the stored record.
- `omitServerResolvedDefaults` and `isRequiredInForm` are untouched. An
option value is a static literal, so it is submitted like any other
seeded value, and a required field the user clears is still refused.
## Public surface: unchanged
`schemaDefaultValues` and `seedCreateValues` are not on the package
entry. They now take a package-local `SeedSchemaLike`, derived from the
published `FieldDefaultsSchemaLike` plus `options` / `multiple`. The
published `FieldDefaultsSchemaLike` keeps exactly its three pinned
members (`parameterTypesNameable-7324.test.ts` passes). No export, prop,
type member or `packages/i18n` key changes. That is why the PR declares
`Clause-②: no`.
## Pins and ablation
`packages/plugin-form/src/__tests__/optionDefaultSeed-11914.test.tsx`,
19 tests:
- `schemaDefaultValues` unit cases for every row of the table above,
plus the control: options that mark nothing seed nothing.
- `ModalForm` (console create dialog), on the tutorial ticket object:
- Priority and Status are preselected and submitted without a pick;
- control: a select that marks nothing stays on its placeholder;
- the user's pick through the control wins;
- a caller seed wins;
- a `multiselect` preselects every marked option (`aria-pressed`);
- an edit form over a row that leaves the key absent is not seeded.
- `ObjectForm` (page-mode create): preselected on create, not applied on
edit.
**Ablation**, run after the fix was committed:
`scripts/ablation-replace.mjs` (objectstack) replaced `const fromOptions
= optionListDefault(f);` with an `undefined` assignment.
- The mutation landed: anchor x1 to x0, blob `a8807e5e` to `bd538283`.
- The pin turned red: 11 failed, 6 passed. These are the same 11 that
failed on `main`.
- The restore is proven: blob equals HEAD, and `git diff HEAD` is empty.
- The tests import source through the root vitest alias, so no `dist/`
is on the measured path.
## Eager closure (Bundle Analysis)
`plugin-form` is eager, so this was measured under the verify lock. The
console `vite build` ran twice from the same worktree, plus
`check-eager-closure-budget.mjs`. The head build was at `27be779f7`. The
base build was the same tree with `schemaDefaults.ts` reverted to
`f1781be3a`; the restore was proven by blob.
| | eager gzip bytes | gate verdict |
|---|---|---|
| base (`f1781be3a`) | 3,385,951 | green, headroom 0.4 KB |
| head | 3,386,104 | green, headroom 0.3 KB |
| **delta** | **+153 gzip** (+379 raw) | |
The growth is in the `plugin-form` chunk (+154 gzip). Other chunks moved
by 1 to 3 bytes from hashed import names. The `vendor-objectstack` chunk
did not move, so `isMultiValueField` was already in the closure. The
change is kept minimal.
Note: `main` `19a7348` is already a few bytes over the 3307.0 KB ceiling
(the seat's main-red card, objectui#11937). This PR's `Bundle Analysis`
is expected red until that card's change lands. It is not addressed
here, and `scripts/check-eager-closure-budget.mjs` is untouched.
## Docs
`packages/plugin-form/README.md`, "What a create form opens with":
- The table row "an option's `default: true`: empty" is replaced.
- So is the paragraph that said only the field-level `defaultValue` is
read.
Both sentences became false with this change. **This file is outside the
claim's file surface.** It was edited because the code change made a
published sentence false, and the objectui `AGENTS.md` docs-driven rule
(#2) applies. The report names it as a deviation; it can be dropped from
the branch if the seat rules otherwise. No sentence under
`content/docs/**` or `skills/**` covers select defaults on create forms.
A grep for the option flag and for create-form defaults found only
`defaultValue` docs about other components.
## Acceptance notes (not changed here)
- **The second form chain.** `apps/console/src/components/FormPage.tsx`
serves `/forms/:name` and `/f/:slug`. It seeds through its own
`readPrefill`, which still reads `defaultValue` alone, so an
option-default select there would still open empty. This is a reading of
the code, not a measured failure. It is outside this claim's surface
(`apps/console`). Sharing the rule would need a published helper, which
would be a `Clause-②` question. Carrier: none named; left to the seat.
- Kanban `InlineQuickAdd` and the calendar's quick-create payload read
`defaultValue` the same way. They were not measured, and no carrier is
named.
## Gates, at head `6da0e6e0b`
- `pnpm exec vitest run` on:
- the new pin;
- the five existing tests that import `schemaDefaults`
(`createDefaults`, `currentUserDefault`, `entrySurface-6059`,
`initialRecordMerge-9760`, `parameterTypesNameable-7324`);
- `column-identity.ratchet.test.ts`.
Result: `Test Files 7 passed (7)`, `Tests 141 passed (141)`.
- `pnpm --filter @object-ui/plugin-form type-check` (`tsc --noEmit &&
tsc -p tsconfig.test.json`) exits 0, after building the
`@object-ui/plugin-form^...` closure. `--listFiles` counts the new test
once.
- `pnpm exec eslint` on the two touched source/test files: 2 files, 0
errors, 0 warnings. ESLint config has no type-aware linting, so
untouched files cannot change verdict.
- All exit 0:
- `node scripts/check-changeset-presence.mjs`
- `node scripts/check-changeset-no-major.mjs`
- `node scripts/check-changeset-overwrite.mjs`
- `pnpm check:changeset-claims`
- `pnpm check:pending-changeset-literals`
- `pnpm check:spec-symbols`
- `pnpm check:new-line-citations` (0 new)
- `pnpm check:control-bytes`
- `node scripts/check-test-path-roots.mjs`
- `node scripts/check-vi-mock-override-shape.mjs`
- `node scripts/check-doc-links.mjs`
- Not run locally (CI): the repo-wide `pnpm lint` / `pnpm check`,
`readme-exports` (no export list changed) and `doc-snippet-types` (no
code fence added).
Changeset: `.changeset/11914-select-option-default.md`,
`@object-ui/plugin-form` patch.
Session: `https://claude.ai/code/session_01MgfduSkFrfM3eorB3UGfAU`
---
_Generated by [Claude
Code](https://claude.ai/code/session_01MgfduSkFrfM3eorB3UGfAU)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent e44f9bc commit ccddd11
4 files changed
Lines changed: 489 additions & 26 deletions
File tree
- .changeset
- packages/plugin-form
- src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
276 | | - | |
| 276 | + | |
| 277 | + | |
277 | 278 | | |
278 | 279 | | |
279 | 280 | | |
| |||
282 | 283 | | |
283 | 284 | | |
284 | 285 | | |
285 | | - | |
| 286 | + | |
286 | 287 | | |
287 | 288 | | |
288 | 289 | | |
289 | 290 | | |
290 | 291 | | |
291 | 292 | | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
299 | 302 | | |
300 | 303 | | |
301 | 304 | | |
| |||
0 commit comments