This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Repository navigation
fix(SchemaForm): render sort repeater rows for union schemas (objectstack#3379) - #2771
Merged
Merged
Conversation
…ui#3379)
Edit View Config → Columns & Filters → Sort rendered a blank repeater:
clicking "Add" produced an empty row with no field picker or order
dropdown. A View's `sort` prop is a union
(`z.union([z.string(), z.array(z.object({ field, order }))])`), so its
JSONSchema is `anyOf: [string, {field,order}[]]`. The repeater read
`schema.items` at the top level — undefined for a union — and derived
zero sub-fields.
Resolve the union to its array branch and use that branch's `items` for
both the derived field list and the per-row controls (`pickSubSchema`).
The legacy bare-string `sort` form stays valid in the spec (its removal
is a separate, deferred deprecation cycle, per view.zod.ts); this is a
renderer-only fix that keeps backward compatibility.
Adds SchemaForm.repeaterUnion.test.tsx covering the empty-value and
existing-array cases.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TVJsp4iA1eNUcwFphoqYu3
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
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.
Problem
In Edit View Config → Columns & Filters → Sort, clicking "Add" produced an empty row with no field picker or order dropdown — users could not configure a default sort at all (objectstack#3379).
Root cause
A View's
sortis authored as a union:so its derived JSONSchema is
anyOf: [ {string}, {array, items:{field,order}} ]. The spec'sviewFormmarkssortas{ type: 'repeater' }, and theSchemaFormrepeater path readschema.itemsat the top level. For a union that isundefined(the array'sitemslive underanyOf[1].items), so the repeater derived zero sub-fields and every added row was blank.Fix (renderer-only, in
SchemaForm.tsx)Add a small
repeaterItemSchema(schema, value)helper that resolves the union to its array branch (reusing the existingresolveUnionBranch, forcing an array value so the score lands on the array member even before any row exists) and returns that branch'sitems. The repeater block now:RepeaterFielda schema whoseitemsis the resolved object schema, so the per-row controls (pickSubSchema) resolve real sub-schemas — thefieldpicker and theorder(asc/desc) select.Plain (non-union) array repeaters pass straight through unchanged.
Deliberate scope decision — spec is not changed
The linked issue suggests dropping the legacy bare-string variant from
ListViewSchema.sortin@objectstack/specand calls that "the true root cause". I did not do that, on purpose:view.zod.tscarries an explicit maintainer instruction directly abovesort: "Removal will go through its own deprecation cycle; do not drop it here", and notes the string form is "kept covered by a live fixture".examples/app-showcase/.../task.view.ts(sort: 'estimate_hours desc'), which exists specifically to guard the objectui#2601 crash. Dropping the union would break it and be a breaking change to the public spec._sectionsconvention (objectstack#5408) #3373 kept the union intentionally and flags this objectui repeater fix as the valid "companion" path.This renderer fix resolves the user-facing bug without any breaking spec change or backward-compat loss. Un-deferring the string-form removal remains a separate maintainer decision — happy to open that as its own PR if desired.
Tests
SchemaForm.repeaterUnion.test.tsxcovers both the empty-value ("Add" surfacesfield+ordercontrols) and existing-array ([{ field, order }]expands to real sub-fields) cases. Both fail without the fix and pass with it. ExistingSchemaForm.*,ViewConfigPanel, andview-config-adaptersuites remain green; lint is clean on the touched code.🤖 Generated with Claude Code
https://claude.ai/code/session_01TVJsp4iA1eNUcwFphoqYu3
Generated by Claude Code