Skip to content

fix(fields,components): a cascade-cleared single select or radio is saved as null (objectui#10291) - #10464

Merged
objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/issue-10291-cleared-scalar-saves-null
Sep 25, 2026
Merged

objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/issue-10291-cleared-scalar-saves-null

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #10291
Clause-②: no

What was wrong

A cascade clear empties an option field when its parent changes and the current value is no longer offered. For a single select or a radio, the clear emptied the field to undefined. The JSON transport leaves out an own key whose value is undefined: @objectstack/client's data.update sends body: JSON.stringify(data). So the field the user saw emptied was never written, and the stored value came back on refresh. The multi-value clear wrote a real [] and was saved.

Measured first, on origin/main 94436f42a, with the new pins (before any edit)

Both pins read the wire body, not the update argument:

  • the inline-edit pin serialises the body the same way the client does;
  • the form pin runs the real @object-ui/data-objectstack adapter and @objectstack/client, with only fetch stubbed.
Path Body on main
Inline edit (real DetailSection + InlineEditSaveBar), parent moved { region: 'apac', tags: [] }. tier and band are missing.
ObjectForm edit, parent moved region, tags: [], tier_any. tier and band are missing.
ObjectForm create, parent moved { region: 'apac', tags: [] }. tier and band are missing.

⇒ The form path loses the value too: premise and reach both confirmed.

The fix, and why this route

The fix is on the widget side, as the seat suggested. The measurement then required one more edit in the same file family.

  1. SelectField / RadioField cascade clear: onChange(undefined) becomes onChange(null). One change covers inline edit, ObjectForm and every other host.
  2. The form renderer's own cascade clear (packages/components/src/renderers/form/form.tsx): setValue(name, undefined) becomes setValue(name, null). This clear runs independently of the widgets. With only step 1 applied, one case was still measured red: an ObjectForm edit whose dependent select is hidden by visibleWhen, so no widget is mounted. The form host clears that field alone, and the PATCH body still lacked tier. The built-in select branch is the same case, because it has no widget clear. The clear-on-hide effect in the same file already writes null, for the reason it documents (objectui#6958 / objectui#6848): an explicit null clears the stored value and an absent key leaves it unchanged.
  3. SelectField renders a null value as "nothing chosen" (next section).

I did not use the save-path mapping (map an own undefined to null on the inline and form save paths). The widgets are where the wrong value is made. Fixing them is one change for every host, where the mapping needs two changes and misses hosts it does not know.

What null does downstream (the four checks)

  • Required validation. isMissingForRequired (@object-ui/core) counts undefined and null as absent. Nothing changes. (Code read.)
  • Dirty tracking. The inline draft holds the key, so it is sent. The master-detail diff (isSameStoredValue) counts null and undefined as one blank, so a pruned field (gold becomes null) is dirty. The form host clear still passes shouldDirty: true.
  • The widget's display of null. Measured in the form: a raw null gave the select trigger empty text and no data-placeholder. It never showed the text "null", but the placeholder disappeared. The widget now absorbs this: null is passed to Radix as '', the controlled spelling of "nothing chosen". undefined is left alone so that no host changes between controlled and uncontrolled. RadioField already rendered value ?? ''. Pinned in SelectField.clearedNull-10291.
  • Whether null is accepted on write for a select. This relies on the write contract documented beside the clear-on-hide effect (objectui#6848: driver-memory merges, driver-sql issues SET for present keys). It was ⛔ NOT MEASURED against a live server in this PR.

Pins (all read the wire body)

  • (a) Inline edit, InlineEditSaveBar.cascadePruneWire-10291. After the parent moves, the body is exactly { region: 'apac', tier: null, band: null, tags: [] }.
  • (b) Form, plugin-form cascadePruneWire-10291:
    • EDIT: tier: null and band: null;
    • EDIT with no widget mounted (host-only clear): tier: null;
    • CREATE: tier: null and band: null.
  • (c) Control: the multi select still writes tags: [] on both paths.
  • (d) Control: a select no parent governs is never nulled.
    • Inline edit: it is absent from the body.
    • Create form: it is absent.
    • Edit form: it is present with its stored 'gold', because an edit form sends its whole value set today. "Only dirty" is objectui#10156, which this PR does not address.
  • Existing prune pins change from undefined to null:
    • the four @object-ui/fields widget suites and the objectui#6153 one;
    • the two components host suites (form-cascade-clear-prefixed-type, form-gated-options-keep-value);
    • the app-shell action-dialog one;
    • the objectui#7190 prune probe. It now counts null and undefined prunes, so a regression still trips its circuit breaker instead of hanging the run.

Ablation (tests resolve @object-ui/fields / @object-ui/components to src through the root vitest aliases, so no build sits between the mutation and the run)

Each leg ran through ablation-replace.mjs (wrap mode, restore trap) at 11a8bbcd6:

  • Leg 1, widgets back to undefined (both files, anchor x1 → x0 each). Result: Tests 7 failed | 9 passed. Red: pin (a), form EDIT, form CREATE, and 4 widget cascade pins. The form host-only case stayed green, as expected for a clear the widgets do not own.
  • Leg 2, form host clear back to undefined. Result: Tests 6 failed | 9 passed. Red: the host-only form pin and 5 components host pins. The inline pin and the mounted-form pins stayed green. The first launch of this leg was refused by the tool before any write ("ANCHOR AMBIGUOUS", x2, because the clear-on-hide line is identical). It was a no-op, and I re-ran it with a unique two-line anchor.
  • Restore, both legs. Blob equals HEAD and git diff HEAD is empty, per the tool's own verdict lines.

Verification (at 11a8bbcd6)

  • pnpm exec vitest run packages/fields/ packages/plugin-detail/ packages/plugin-form/ packages/components/src/renderers/form/ from the repo root, plus these files:
    • the app-shell tests that exercise option cascades;
    • the plugin-grid and plugin-list tests that exercise option cascades;
    • apps/console FormPage.*.
    • Result: Test Files 598 passed | 2 skipped (600), Tests 7052 passed | 26 skipped (7078).
  • type-check, after turbo run build of the dependency closure: @object-ui/fields, components, plugin-detail, plugin-form, app-shell all Done. The touched test files are in each package's tsconfig.test.json program (--listFilesOnly).
  • check:control-bytes OK. check:new-line-citations reported 0 new citation(s). check-changeset-presence ✅. check:changeset-claims exit 0.
    • check:changeset-claims flagged 3 pending changesets that name form.tsx. I read each one, and each is about an unrelated part of that file: the FormPage chain, section-divider className, and description wiring. None is falsified.
  • More checks that passed: check:vi-mock-* ×3, check:test-path-roots, check:phantom-deps, check:doc-fences, check:doc-example-ids, check:pending-changeset-literals, and the governed-surface test (NOT GOVERNED). check:doc-snippets was ⛔ NOT MEASURED: its prerequisite is a whole-tree build, which is left to CI.
  • ESLint over the 15 touched .ts/.tsx files (--format json), compared with base through --stdin: 0 errors. no-explicit-any warnings went from 121 to 133. All +12 are in the two new test files, and they are the same as any host-prop casts as the neighbouring suites. react-refresh 7 → 7, no-unused-vars 1 → 1.

Scope note: the claim's file surface was exceeded (flagged, not settled here)

The claim named the two widgets, the tests beside them, InlineEditSaveBar if needed, and one changeset. This PR also touches these files:

  • form.tsx and its two host suites (the measured form-path gap above);
  • two app-shell tests that pin the old undefined;
  • one sentence in content/docs/fields/select.mdx.

When the edits were made:

  • no open PR (14 read) touched form.tsx;
  • no live claim (21 read) named it.

The seat decides whether to accept this surface or split it off.

Acceptance notes

  • FieldWidgetComponentProps.onChange is typed (val: T) => void, so every clearing widget casts its null (null as unknown as string, onChange(null as any)). Not changed here, because that would change an exported signature.
  • Hosts that pass SelectField a value that turns into undefined still switch Radix from controlled to uncontrolled. The cascade clear no longer causes that switch.

Changeset

.changeset/10291-cleared-scalar-saves-null.md: minor on @object-ui/fields and @object-ui/components, because a cleared value is now saved.

Implemented by os-dev in session https://claude.ai/code/session_01BA3nKVUwKQJf8DBxrSVtNC.


Generated by Claude Code

…aved as null (objectui#10291)

A single select or radio emptied by a cascade clear staged `undefined`,
which `JSON.stringify` omits from the PATCH/POST body, so the value the
user saw cleared was never written and came back on refresh -- on the
record page's inline edit and in forms. The multi-value clear beside it
wrote a real array and was saved.

- SelectField / RadioField emit `null` from their cascade clear.
- The form renderer's own cascade clear sets `null`: it is the only clear
  for a field no option widget renders (a `visibleWhen`-hidden field, the
  built-in select branch).
- SelectField renders a `null` value with its placeholder, as it does `''`.

Pins observe the wire body: the inline-edit save (plugin-detail) and the
form edit/create saves through the real data-objectstack adapter
(plugin-form). Existing prune pins move from `undefined` to `null`.

Claude-Session: https://claude.ai/code/session_01BA3nKVUwKQJf8DBxrSVtNC
@github-actions

Copy link
Copy Markdown
Contributor

changeset-claim-re-read

⚠️ 3 pending changeset(s) describe a file this change touches

Their bodies publish verbatim into the CHANGELOG at the next release, so this is a request to re-read them against your diff — addressed here because you are the one seat that can answer it without re-deriving anything.

⛔ Nothing here blocks, and nothing here is a verdict on your change. This gate exits 0, is not a required context, and judges name resolution, never meaning: it asked whether a pending body names a file you touched. "Is this sentence still true?" is the one question it will not answer, and the one you are being asked to answer.

.changeset/console-formpage-visible-predicates-5594.md

.changeset/plugin-form-readme-classname-quantifier-5131.md

  • names packages/components/src/renderers/form/form.tsx → packages/components/src/renderers/form/form.tsx — edited by this change

    README.md's "Not a FormField key" table said a field-level className is "read on exactly one pseudo-field, type: 'section-divider'". That quantifier holds only for the renderer's explicit read — className={fp.className} on the section-divider branch of packages/components/src/renderers/form/form.tsx. The same renderer forwards every key it did not destructure, and className is not among the names taken off the field config, not among the ones stripRendererOnlyProps removes, and so rides {...fieldProps} into renderFieldComponent, whose built-in input branch spreads it onto ANGLE-BRACKETS(Input). A field-level className therefore lands visibly on ordinary built-in controls, and a reader taking "exactly one" literally concludes the opposite of what the code does (objectui#5131).

.changeset/text-input-description-aria-describedby-5735.md

  • names renderers/form/form.tsx → packages/components/src/renderers/form/form.tsx — edited by this change

    Before this the paragraph and the input were siblings with no programmatic relationship: a screen reader moving to the field announced the label and the value and never the helper text. The label half of the same block was already wired (htmlFor against the input's id), which is what made the gap specific to description rather than a general absence of a11y wiring — and the identical key authored on a field INSIDE renderers/form/form.tsx has been announced all along, so one authoring key behaved two ways depending on which container the author reached for. It no longer does.

Read the paragraph, not the line: both false halves of the objectui#8617 claim sat in one paragraph, and correcting either alone would have left it asserting the same wrong thing.

If a claim did go false, correct the body. That is precedented and prose-only, frontmatter untouched; check-changeset-overwrite.mjs will report the correction as its own case 2 ("correcting a declaration on purpose … legitimate"), which is the intended shape — one gate asks for the read, the other records the write.

Not covered, stated so nobody reads this as more: a born-false claim that spells no line address at all (objectui#9495 coordinated one by ORDINAL — "a grep finds that member first" — and deciding that means reading what the sentence means), a claim spelled as a symbol or a package rather than a backticked file name, and a file named ambiguously.

Angle-bracketed names in the quoted prose above are rewritten as ANGLE-BRACKETS(name): GitHub deletes tag-shaped fragments from a stored body, and a quote that silently loses the identifier it is about is worse than a visible repair.

Compared the checked-out tree with e6203d756 (merge-base with origin/main): 16 file(s) changed outside .changeset/, read against 1395 pending declaration(s) that publish a body (1973 pending in total). · run

@github-actions

Copy link
Copy Markdown
Contributor

✅ Console Performance Budget

Metric Value Budget
Eager closure (gzip, 329 chunks) 3044.7 KB 3104.5 KB
Main entry chunk (gzip) 147.8 KB 350 KB
Entry file index-CzxibiRy.js —
Status PASS —

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

Package Size Gzipped
app-shell (consoleActionDispatch.js) 0.20KB 0.19KB
app-shell (index.js) 16.68KB 6.20KB
app-shell (runtime-config.js) 20.68KB 7.36KB
app-shell (types.js) 0.01KB 0.04KB
app-shell (urlParams.js) 10.06KB 3.86KB
auth (ActiveOrganizationStorage.js) 27.95KB 10.04KB
auth (AuthContext.js) 0.31KB 0.24KB
auth (AuthGuard.js) 2.07KB 1.00KB
auth (AuthProvider.js) 40.18KB 10.59KB
auth (AuthShell.js) 3.49KB 1.40KB
auth (ForgotPasswordForm.js) 12.21KB 3.45KB
auth (LoginForm.js) 18.15KB 5.39KB
auth (PreviewBanner.js) 0.90KB 0.50KB
auth (RegisterForm.js) 6.65KB 2.22KB
auth (SocialSignInButtons.js) 9.61KB 3.89KB
auth (UserMenu.js) 3.41KB 1.23KB
auth (auth-gate-events.js) 1.29KB 0.66KB
auth (authStyles.js) 5.04KB 1.72KB
auth (createAuthClient.js) 40.21KB 10.80KB
auth (createAuthenticatedFetch.js) 8.52KB 3.45KB
auth (index.js) 3.63KB 1.64KB
auth (invitation-status.js) 1.22KB 0.70KB
auth (org-roles.js) 6.66KB 2.78KB
auth (phone-identifier.js) 1.11KB 0.66KB
auth (types.js) 0.59KB 0.35KB
auth (useAuth.js) 5.30KB 1.02KB
auth (useWorkspaceAdminStatus.js) 11.08KB 4.58KB
collaboration (CommentThread.js) 27.13KB 7.95KB
collaboration (LiveCursors.js) 3.17KB 1.27KB
collaboration (PresenceAvatars.js) 6.49KB 2.64KB
collaboration (PresenceProvider.js) 2.79KB 1.13KB
collaboration (index.js) 1.68KB 0.73KB
collaboration (useCollaborationTranslation.js) 6.05KB 2.52KB
collaboration (useCommentSearch.js) 1.98KB 0.88KB
collaboration (useConflictResolution.js) 7.75KB 1.86KB
collaboration (useMentionNotifications.js) 1.81KB 0.68KB
collaboration (usePresence.js) 6.33KB 1.84KB
collaboration (useRealtimeSubscription.js) 7.91KB 2.01KB
components (index.js) 543.20KB 129.68KB
core (index.js) 9.22KB 3.71KB
create-plugin (index.js) 27.94KB 9.51KB
data-objectstack (index.js) 223.86KB 62.25KB
fields (index.js) 256.90KB 65.08KB
i18n (LocalizationContext.js) 1.76KB 0.96KB
i18n (builtinAggregateLabels.js) 0.86KB 0.49KB
i18n (currency.js) 1.22KB 0.64KB
i18n (fallbackInterpolation.js) 6.25KB 2.77KB
i18n (i18n.js) 8.87KB 3.64KB
i18n (index.js) 5.24KB 2.27KB
i18n (pickLocalized.js) 9.86KB 3.95KB
i18n (provider.js) 39.40KB 12.91KB
i18n (useDisplayLocale.js) 3.52KB 1.76KB
i18n (useObjectLabel.js) 34.34KB 9.17KB
i18n (useSafeTranslation.js) 5.60KB 2.33KB
layout (index.js) 39.28KB 11.09KB
mobile (MobileProvider.js) 0.92KB 0.49KB
mobile (ResponsiveContainer.js) 0.94KB 0.38KB
mobile (breakpoints.js) 1.51KB 0.70KB
mobile (createOfflineDataSource.js) 5.61KB 1.75KB
mobile (index.js) 1.99KB 0.87KB
mobile (offlineQueue.js) 3.91KB 1.35KB
mobile (pwa.js) 0.97KB 0.49KB
mobile (serviceWorker.js) 1.48KB 0.62KB
mobile (serviceWorkerSource.js) 3.41KB 1.48KB
mobile (useBreakpoint.js) 1.54KB 0.65KB
mobile (useGesture.js) 6.96KB 1.98KB
mobile (useOfflineSync.js) 1.99KB 0.72KB
mobile (usePullToRefresh.js) 6.62KB 2.45KB
mobile (useResponsive.js) 0.72KB 0.42KB
mobile (useSpecGesture.js) 5.52KB 2.10KB
mobile (useTouchTarget.js) 1.01KB 0.54KB
permissions (MePermissionsProvider.js) 13.52KB 4.88KB
permissions (PermissionContext.js) 0.31KB 0.25KB
permissions (PermissionGuard.js) 0.89KB 0.45KB
permissions (PermissionProvider.js) 6.24KB 2.16KB
permissions (discardProofCache.js) 1.04KB 0.55KB
permissions (evaluator.js) 8.39KB 3.10KB
permissions (index.js) 0.93KB 0.41KB
permissions (store.js) 0.91KB 0.42KB
permissions (useFieldPermissions.js) 1.28KB 0.53KB
permissions (usePermissions.js) 4.83KB 2.27KB
plugin-ai (index.js) 16.01KB 3.93KB
plugin-calendar (index.js) 51.22KB 14.56KB
plugin-charts (index.js) 74.76KB 20.82KB
plugin-chatbot (index.js) 198.36KB 47.20KB
plugin-dashboard (index.js) 133.59KB 35.39KB
plugin-designer (index.js) 216.12KB 44.37KB
plugin-detail (index.js) 231.66KB 61.23KB
plugin-editor (index.js) 2.23KB 1.05KB
plugin-form (index.js) 146.34KB 37.47KB
plugin-gantt (index.js) 168.25KB 41.46KB
plugin-grid (index.js) 215.43KB 58.90KB
plugin-kanban (index.js) 49.30KB 15.39KB
plugin-list (index.js) 114.37KB 28.24KB
plugin-map (index.js) 21.83KB 7.07KB
plugin-markdown (index.js) 13.88KB 4.80KB
plugin-report (index.js) 43.55KB 11.99KB
plugin-timeline (index.js) 30.64KB 8.94KB
plugin-tree (index.js) 10.52KB 3.69KB
plugin-view (index.js) 87.90KB 21.97KB
providers (DataSourceProvider.js) 0.75KB 0.39KB
providers (MetadataProvider.js) 1.37KB 0.59KB
providers (ThemeProvider.js) 1.90KB 0.85KB
providers (UploadProvider.js) 11.66KB 3.50KB
providers (index.js) 0.45KB 0.23KB
providers (types.js) 0.01KB 0.04KB
react-runtime (index.js) 5.62KB 2.34KB
react (LazyPluginLoader.js) 4.47KB 1.63KB
react (SchemaRenderer.js) 114.58KB 37.60KB
react (data-invalidation.js) 5.05KB 2.08KB
react (index.js) 4.03KB 1.86KB
react (schema-input.js) 4.25KB 2.04KB
react (spec-input.js) 0.20KB 0.18KB
sdui-parser (body-dialect.js) 4.78KB 2.09KB
sdui-parser (codegen.js) 6.58KB 2.74KB
sdui-parser (dashboard-widget-options.js) 3.08KB 1.30KB
sdui-parser (index.js) 5.78KB 2.56KB
sdui-parser (input-type.js) 2.84KB 1.40KB
sdui-parser (kanban-quick-add.js) 3.89KB 1.87KB
sdui-parser (parse.js) 25.28KB 7.80KB
sdui-parser (provenance.js) 3.66KB 1.82KB
sdui-parser (types.js) 0.28KB 0.23KB
sdui-parser (validate.js) 18.27KB 6.20KB
types (ai.js) 4.11KB 2.06KB
types (api-types.js) 0.20KB 0.18KB
types (app.js) 2.87KB 1.00KB
types (base.js) 0.20KB 0.18KB
types (blocks.js) 0.20KB 0.18KB
types (complex.js) 2.93KB 1.49KB
types (crud.js) 0.20KB 0.18KB
types (dashboard-filter-alias.js) 6.23KB 2.74KB
types (data-display.js) 3.75KB 1.85KB
types (data-protocol.js) 0.20KB 0.19KB
types (data.js) 0.20KB 0.18KB
types (designer.js) 1.85KB 0.85KB
types (disclosure.js) 0.20KB 0.18KB
types (error-code.js) 1.54KB 0.88KB
types (expression.js) 0.20KB 0.18KB
types (feedback.js) 0.20KB 0.18KB
types (field-types.js) 0.20KB 0.18KB
types (form.js) 0.20KB 0.18KB
types (http-inflight.js) 8.87KB 3.73KB
types (http-retry.js) 4.32KB 2.02KB
types (icon-key-migration.js) 4.26KB 1.63KB
types (index.js) 4.74KB 2.25KB
types (layout.js) 0.20KB 0.18KB
types (managed-by.js) 0.19KB 0.18KB
types (mobile.js) 5.00KB 2.39KB
types (navigation.js) 0.20KB 0.18KB
types (objectql.js) 0.20KB 0.18KB
types (overlay.js) 0.20KB 0.18KB
types (permissions.js) 0.20KB 0.18KB
types (plugin-scope.js) 0.20KB 0.18KB
types (record-components.js) 0.20KB 0.19KB
types (record-semantics.js) 1.28KB 0.67KB
types (registry.js) 0.20KB 0.18KB
types (reports.js) 0.20KB 0.18KB
types (select-option.js) 0.20KB 0.19KB
types (spec-report.js) 5.05KB 1.93KB
types (spec-ui-namespace.js) 0.20KB 0.19KB
types (strict-authoring-face.js) 17.15KB 6.32KB
types (system-fields.js) 3.33KB 1.54KB
types (theme.js) 6.28KB 2.87KB
types (ui-action.js) 8.11KB 3.32KB
types (views.js) 0.20KB 0.18KB
types (widget.js) 0.20KB 0.18KB

Size Limits

  • ✅ Core packages should be < 50KB gzipped
  • ✅ Component packages should be < 100KB gzipped
  • ⚠️ Plugin packages should be < 150KB gzipped

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review September 25, 2026 03:40
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Sep 25, 2026
Merged via the queue into main with commit 274e14a Sep 25, 2026
45 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-10291-cleared-scalar-saves-null branch September 25, 2026 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant