Skip to content

fix(utils): keep array items when the items schema did not change - #5460

Merged
heath-freenome merged 2 commits into
rjsf-team:v7from
charan-rathore:fix/scalar-enum-placeholders
Oct 12, 2026
Merged

heath-freenome merged 2 commits into
rjsf-team:v7from
charan-rathore:fix/scalar-enum-placeholders

Conversation

@charan-rathore

@charan-rathore charan-rathore commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #5451.

Description

On v7, sanitizeDataForNewSchema filters array items against the items enum on every sanitize pass. Because the old side was resolved against the current data, a conditional that flipped between the previous data and now showed up with identical-looking items schemas, and the filter then deleted values the user had legitimately entered (or unfilled minItems placeholders) when an unrelated sibling field's schema changed. Form sanitizes on every change, so any conditional form could lose entered array items this way.

The fix, after review with @heath-freenome:

  • sanitizeDataForNewSchema takes an optional trailing oldData argument (the previous form data), threaded down the recursion. Without it, behavior is exactly as before, so existing direct callers are unaffected; Form passes the data as it last settled.
  • The old side resolves against the previous data via a new resolvedOldSchema parameter: FormState stores settledFormData and the settledRetrievedSchema from the last settling pass, so the old-vs-new comparison sees a conditional flip as a real difference and the enum filter still runs when it should (A nested dependencies branch switch never sanitizes, so a narrowed select keeps an invalid value #5250 stays fixed), while an unchanged items schema no longer filters.
  • Array rows pair against their own prior position, not a shifted neighbor's, so a declined remove/reorder no longer feeds a row another row's previous value.
  • The enum filter keeps a fast path (raw keyed-schema equality plus a deepEquals gate), so a kept out-of-enum value does not pay a resolve per pass. The maxItems slice behavior is unchanged.

resolvedOldSchema is a caller-supplied schema, documented in the JSDoc, utility-functions.md, the v7 upgrade guide and the CHANGELOG-v7.md entry. The marker that tracks settled data is dropped when its root no longer matches, and an empty marker fails hasSettledData.

What settles the snapshot

Settles:

  • A sanitize pass the form runs on a change (shouldSanitize: scalar edits and whole-value selects).
  • The first render, which settles the starting data.
  • A parent's push the form accepts through acceptedProposal: the pushed value becomes the settled data.

Does not settle:

  • Container writes (array add, copy, remove, reorder). These announce their move instead, and the pairing view moves with the rows, so the next sanitize pairs each row with its own previous value.
  • A parent's push that matches no pending proposal.
  • Resets and root schema changes: the settled marker is dropped when its root no longer matches, and placeholders do not survive the first edit after a root schema change.

Verification

Checklist

  • I have read the documentation
  • In the case of a bug fix, I have added tests to prove that my fix is effective and existing tests are passing
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation (JSDoc, utility-functions.md, v7 upgrade guide, CHANGELOG entry)
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Size limit report

Sizes are minified + brotli, measured by size-limit at 25584c7.

A package listed twice is measured both as installed and, on the second row, as its own code with its dependencies excluded. Peer dependencies are always excluded.

Check Base PR Δ
@rjsf/antd 7.19 kB 7.19 kB =
@rjsf/antd (without dependencies) 6.76 kB 6.76 kB =
@rjsf/chakra-ui 18.84 kB 18.84 kB =
@rjsf/chakra-ui (without dependencies) 10.73 kB 10.73 kB =
@rjsf/core 30.70 kB 31.32 kB +0.62 kB
@rjsf/core/markdown 25.53 kB 25.53 kB =
@rjsf/core/testing 60.82 kB 60.90 kB +0.08 kB
@rjsf/core: Form 30.39 kB 31.06 kB +0.67 kB
@rjsf/daisyui 54.08 kB 54.08 kB =
@rjsf/daisyui (without dependencies) 11.20 kB 11.20 kB =
@rjsf/fluentui-rc 5.76 kB 5.76 kB =
@rjsf/mantine 14.44 kB 14.44 kB =
@rjsf/mantine (without dependencies) 10.03 kB 10.03 kB =
@rjsf/mui 6.59 kB 6.59 kB =
@rjsf/react-bootstrap 7.72 kB 7.72 kB =
@rjsf/react-bootstrap (without dependencies) 5.30 kB 5.30 kB =
@rjsf/shadcn 43.55 kB 43.55 kB =
@rjsf/shadcn (without dependencies) 9.27 kB 9.27 kB =
@rjsf/utils 29.86 kB 30.12 kB +0.26 kB
@rjsf/utils (without dependencies) 24.34 kB 24.58 kB +0.24 kB
@rjsf/utils: getUiOptions 0.65 kB 0.65 kB =
@rjsf/validator-ajv8 38.14 kB 38.14 kB =
@rjsf/validator-ajv8 (without dependencies) 2.66 kB 2.66 kB =
@rjsf/validator-ata 86.24 kB 86.24 kB =
@rjsf/validator-ata (without dependencies) 2.41 kB 2.41 kB =
@rjsf/validator-cfworker 7.22 kB 7.22 kB =
@rjsf/validator-cfworker (without dependencies) 2.30 kB 2.30 kB =

@heath-freenome heath-freenome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. The guard does keep the minItems placeholders (I confirmed [null, null] now survives an unrelated sibling-schema change). But it special-cases the symptom: the enum filter still runs when the items schema hasn't changed, and the maxItems slice now prefers empty slots over values. Details are inline. I ran every scenario below against this branch and against main before the PR.

One point couldn't go inline because the line is outside the diff:

Array-form item type never matches (sanitizeDataForNewSchema.ts:245, pre-existing). oldSchemaType === newSchemaType compares by reference, so type: ['string', 'null'] taken from two different schema objects never matches, and the whole list is cleared. Old items { type: ['string','null'], enum: ['a','b'] }, new items { type: ['string','null'], enum: ['a'] }, data ['a', 'b'] -> list becomes undefined, not ['a']. Line 154 does the same for property keys. This isn't introduced here, but it's the same function and the same "list unexpectedly emptied" symptom.

Also, please add a changelog entry as the last bullet under ## @rjsf/utils in CHANGELOG.md. It should mention the changed maxItems behavior too, unless that changes per the inline comment.

@heath-freenome

Copy link
Copy Markdown
Member

A note on how this code looks on v7, since the same filter lives there (sanitizeDataForNewSchema.ts:265, as the issue says). I ran the same scenarios against v7 (65fb46692), this branch, and main before the PR:

Case main before this PR v7
[null, null], same schema / sibling schema change (#5451) [] [null, null] []
['a', 'legacy'], same schema / sibling schema change ['a'] ['a'] ['a']
[null, 'a', undefined, 'b'], maxItems: 2 ['a', 'b'] [null, 'a'] ['a', 'b']
['a', null], maxItems: 0 ['a'] ['a', null] []
array-form item type, narrowed enum undefined undefined undefined
{ field: null, list: [null] }, enum: ['a'] field: 'a', list: [] field: 'a', list: [null] field: 'a', list: []

So v7 has #5451 and the 'legacy' data loss too, and needs the same fix. It already handles maxItems: 0 (maxItems >= 0). It also already computes sameItemsSchema = deepEquals(oldSchemaItemsRaw, newSchemaItemsRaw) a few lines above the filter, so the change suggested inline (skip the enum filter when the items schema didn't change) is a one-condition change there, and it keeps the maxItems slice behavior as it is.

@heath-freenome

Copy link
Copy Markdown
Member

Following up on the v7 note above: since v7 already has the sameItemsSchema comparison and the maxItems >= 0 fix, maybe this fix should move there. Retarget this PR to v7, skip the enum filter when sameItemsSchema is true, and add a test for the issue's sibling-schema-change trigger in the shared sanitizeDataForNewSchemaTest.ts suite. If #5451 also needs fixing in a 6.x release, the same one-condition change (computing the deep-equal comparison of the raw items schemas, which main also does just above) could still go to main on its own.

@charan-rathore

Copy link
Copy Markdown
Contributor Author

@heath-freenome Retargeted to v7 and reworked as suggested.

What changed:

  • The enum filter is now skipped when sameItemsSchema is true (the deep-equal comparison of the raw items schemas that v7 already computes), so an unrelated sibling-schema change no longer drops entered values or unfilled minItems slots. The maxItems slice behavior is unchanged (v7's maxItems >= 0 handling stays as is).
  • A literal one-condition skip regressed four existing tests, so the skip has two qualifiers:
    • Selects over object/array constants (isWholeValueSelect) still filter against an unchanged items schema, keeping the sanitizeDataForNewSchema() drops array elements a narrowed items enum rejects for scalar items but keeps them for object items #5346 behavior (leaves an empty items enum beside a list of object constants, both keeps array items picked from object constants cases).
    • A property the new schema just introduces still filters: the property loop passes the new keyed schema down as the old one for new array properties, so "unchanged" there only means there was no prior constraint. That is now an explicit parameter rather than an accident of the stand-in.
  • New test for the issue's sibling-schema-change trigger added to the shared sanitizeDataForNewSchemaTest.ts: red on current v7 (list collapses to ['a']), green with the fix.
  • Changelog entry added as the last bullet under ## @rjsf/utils. Since the v7 change leaves the maxItems slice untouched, it does not mention a maxItems behavior change.

Ran: packages/utils test/schema.test.ts 927/927 and packages/validator-ajv8 test/utilsTests/schema.test.ts 3284/3284, plus a typecheck of the touched package (no errors in the changed files; a few pre-existing errors in validator-cfworker test files are untouched).

On your non-inline point about array-form item type (oldSchemaType === newSchemaType comparing by reference, line ~245): confirmed pre-existing and reproducible - two structurally identical type: ['string', 'null'] arrays from different schema objects never match, so the list is cleared. Same for property keys at line 154 as you noted. I left it out of this PR to keep the change reviewable; happy to send it as a separate PR against v7 with a deep-equal comparison if you want it.

If #5451 also needs a 6.x fix on main, the same one-condition change applies there (main computes the raw-items deep-equal just above the filter as well); say the word and I'll open that separately.

Comment thread CHANGELOG.md Resolved
@charan-rathore

Copy link
Copy Markdown
Contributor Author

@heath-freenome Moved the changelog entry from CHANGELOG.md to CHANGELOG-v7.md (last bullet under ## @rjsf/utils), pushed as f0cc524. The touched files are clean under the repo's pinned oxlint 1.85.0.

@heath-freenome heath-freenome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick rework. Everything from the first round is addressed: the retarget, the shared-suite test with the sibling-change trigger, CHANGELOG-v7.md, and the null exemption and maxItems slice issues, which are gone now.

I ran another pass over the new head (f0cc524). The first inline comment is the important one, and it's a hole in the approach I suggested, not something you introduced: with a nested if/then, "the raw items schema didn't change" is the wrong signal, because the keyed schemas there are already resolved against the data. I confirmed it and the new-array-of-objects case against v7 (65fb46692) with throwaway tests. The rest are smaller.

@charan-rathore

Copy link
Copy Markdown
Contributor Author

@heath-freenome Both regressions reproduced as failing tests first, then fixed. Pushed as 900fca3.

Nested if/then (the big one): confirmed - with the raw schemas identical, the keyed schemas are reused already resolved against the current data, so sameItemsSchema was true even after the condition flipped which enum applies. Your exact scenario went red (['a', 'b'] survived), now green (['a']). The fix: the skip only holds when neither side was resolved into a different shape on the way in. Resolution changes are detected per level (resolved vs raw at the property loop and at the array branch) and threaded down the recursion through an internal helper, so the exported signature stays at five parameters - the docs and upgrade-guide signature table match again, and there is no public flag to document or misuse. $ref items get the same treatment for free: a $ref never resolves to its raw text, so those always filter, which covers your different-roots point as far as this layer can see it.

Newly introduced array-of-objects: the flag is gone. The property loop now passes a neutral { type: 'array', items: {} } stand-in as the old schema, so sameItemsSchema reads false there, the per-element recursion gets {} as the old item schema, and nested properties (like your rows[].tags) are seen as new and filtered. Your scenario red-then-green as well. I verified the stand-in against the suite rather than taking it on faith: 929/929 in packages/utils, 3292/3292 under validator-ajv8.

Also in this push:

  • shouldFilter flattened to your suggested shape (a nested ternary I introduced tripped no-nested-ternary; clean now under oxlint 1.85.0).
  • JSDoc flow description updated for the skip and its exceptions.
  • Upgrade guide sanitizeDataForNewSchema() bullet now names the skip and when it does not apply.
  • Changelog entry and PR description name the two known limits you called out: placeholders still collapse when the items schema itself changes, and lists of object/array constants are still filtered against an unchanged items schema. I left the Fixes #5451 link since the issue's sibling-change repro is fixed; say the word if you'd rather scope it to a partial fix.

@heath-freenome heath-freenome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for turning this around so quickly. Both regressions from last round are fixed, the public signature is back to five parameters, and the docs and shouldFilter cleanup are what I asked for.

I ran another pass against 900fca35, checking each scenario against the PR source with the ajv8 validator. The summary is uncomfortable, and most of it is on me: #5451 still isn't fixed for the schema shape that makes Form sanitize on every change (first inline comment). Two of the new problems come straight from the { type: 'array', items: {} } stand-in that I suggested (comment on line 196).

I think this is the third round in a row where a gate on the array-enum branch closes one hole and opens another. There are now five of them: sameItemsSchema, itemsResolvedAsWritten, conditionalResolvedUpstream, isWholeValueSelect and the stand-in. My original one-condition suggestion was the wrong fix, and I'd rather not ask you for a sixth gate. The comment on line 312 has what I think the root cause is and a direction that would handle it in one place. I'd like to agree on the approach before more code changes.

@charan-rathore

Copy link
Copy Markdown
Contributor Author

Thanks for another careful pass, and no apology needed on the stand-in. I reproduced every one of these against 900fca35 with the ajv8 validator before writing this, so take these as confirmed rather than agreed-in-principle:

  1. Unrelated nested if/then: { obj: { pick: 'x', list: [null, null] } } comes back { obj: { pick: 'x', list: [] } }. Agreed this is the real sanitizeDataForNewSchema() drops the empty minItems placeholders of a scalar enum array, so any change in a form with a conditional empties the list #5451 shape, since hasNestedConditionalSchema is exactly what puts Form on the sanitize-on-every-change path, and my sibling-change test only passed because its schema had no conditional at all.
  2. New array property with items: true: { tags: ['x', 1] } comes back {}. The {} vs true pair matches neither branch, so a root if/then or oneOf switch that reveals such a property deletes its data.
  3. New array of objects: rows come back as { k: 'D', ro: 'R' } and { k: 'D' }, defaults filled including the readOnly one. Neither CHANGELOG-v7.md nor the upgrade guide mentions this.
  4. Stable rewrites turn the fix off: items: { allOf: [...] } gives ['a'], the additionalProperties stub case gives ['a'], and items behind a $ref gives ['a']. "Resolved into a different shape" is not "depends on the data", and you're right that all three are stable schemas.
  5. Scalar/array mismatch: one: 'legacy' is cleared by replacementForInvalidEnumValue while list: ['legacy'] survives.

On the root cause I think you're exactly right. Both sides are resolved against the current data, so every gate in shouldFilter is reconstructing after the fact whether a resolution was data-dependent, and each reconstruction misclassifies something: resolution-taint kills the fix for stable rewrites, conditionalResolvedUpstream kills it for unrelated conditionals, and the stand-in manufactures a difference that has its own side effects. Resolving the old side against the previous data removes the ambiguity at the source: a flipped condition shows up as a genuinely different resolved old schema, a stable rewrite resolves the same on both sides, and no stand-in is needed.

I'd be glad to take that on. The shape I'd expect: Form already has the previous formData at the point it sanitizes, so it could resolve the old schema against that before calling sanitizeDataForNewSchema, or the util could take the previous data as an optional argument so existing direct callers keep working. Either way the five gates collapse into an honest comparison.

But it changes what the util receives, so I'd rather settle the direction before writing it. As I see it:

  • Prototype the previous-data resolution here (or on a follow-up PR if you'd rather land the small fixes first), or
  • Scope this PR down honestly: keep the skip only for the plain case where the items schemas are equal as written and nothing resolved on either side, drop Fixes #5451, and rewrite the changelog bullet to describe what the code actually does rather than the narrower rule I wrote.

Happy to go whichever way you and the team prefer. If you want to see the prototype, I'll build it red-first against the seven cases from this round and the two regressions from the last one.

On the smaller points: agreed on hoisting itemsResolvedAsWritten out of the reduce (it is element-invariant) and on sharing one helper across the three comparison sites. Whichever direction we take, I'll fold those in.

@heath-freenome

Copy link
Copy Markdown
Member

@charan-rathore Thanks for re-running every case and for laying out the options so clearly. Let's go with the prototype, and do it here: this PR's current gates would all be replaced anyway, so reworking it in place keeps the history and the discussion together.

On the shape, I'd go with the optional trailing argument for the previous data, passed down through the recursion, rather than having Form resolve the old schema before the call. Form can only resolve the top level. Every keyed schema and items schema below that is resolved inside the util, which is where both #5250 and #5451 happen, so the util needs the previous data at every level. Some notes:

  • Without the argument, behavior stays as it is today (both sides resolved against the current data), so existing direct callers aren't affected. Form passes its previous formData.
  • Per-element items: resolving the old item schema against "the previous element" needs a rule for which element that is. Pairing by index is the obvious choice, but an insert, remove or reorder would compare against a different element's data. Please pick a rule, say in the code why, and add one test that pins it down.
  • New properties: with no previous value, resolution should give the right answer without the { type: 'array', items: {} } stand-in. If that holds, please drop the stand-in, which also clears the items: true and filled-in-defaults problems.
  • Tests first, as you suggested: the seven cases from the last round plus the two regressions before that (nested if/then narrowing, and the nested array inside a new array of objects). Also add one case through Form (or at least through SchemaUtils with the previous data) for the sanitizeDataForNewSchema() drops the empty minItems placeholders of a scalar enum array, so any change in a form with a conditional empties the list #5451 shape. It's the path users actually hit, and none of the current tests go through it.
  • Scalar path: if the same comparison lets replacementForInvalidEnumValue skip an unchanged scalar, please include it so the scalar and array paths agree. If that turns out to be a separate change, say so in the PR description and leave it for later.
  • Docs: the new argument needs a @param, an entry in the utility-functions.md Parameters list and in the upgrade guide's signature table, and a changelog entry that describes the comparison rather than listing exceptions.

The hoisting and shared-helper nits will probably disappear with the gates, so don't spend time on them in the current code.

Since this changes what the util receives, other maintainers may weigh in on the signature, but please go ahead with the prototype.

@charan-rathore

Copy link
Copy Markdown
Contributor Author

@heath-freenome Reworked along the lines we agreed, pushed as 7c754ab.

  • sanitizeDataForNewSchema takes an optional trailing oldData (the previous form data), threaded down the recursion. The old side resolves against the previous value at each position, so a conditional that flipped between previous and current data shows up as a real old-vs-new difference and still filters (A nested dependencies branch switch never sanitizes, so a narrowed select keeps an invalid value #5250), while an unrelated conditional resolves the same on both sides and keeps the data (sanitizeDataForNewSchema() drops the empty minItems placeholders of a scalar enum array, so any change in a form with a conditional empties the list #5451). Without the argument, both sides resolve against the current data - same behavior as before, so existing callers are unaffected. Form passes its previous formData.
  • Per-element items pair by index: the only rule that needs no identity of its own, at the cost of comparing against a different element's previous value on insert/remove/reorder. That trade-off is in a code comment and pinned by a test.
  • The { type: 'array', items: {} } stand-in is dropped: with no previous value, resolution alone gives the right answer for new properties, which also clears the items: true and filled-in-defaults cases.
  • The scenarios from your last two rounds plus the pairing pin all live in one describe that goes through SchemaUtils with previous data, the path Form takes.

Verification: packages/utils suite green (938 tests; one pre-existing utcToLocal failure in this sandbox's timezone, identical on pristine v7), both touched source files at 100% statements/branches/functions/lines, oxlint clean lint-only - oxlint --type-check OOMs in this sandbox even scoped to the touched files, so it was not part of the gate. Docs, the upgrade guide, and CHANGELOG-v7.md are updated for the new parameter.

@heath-freenome heath-freenome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the rework. The shape is what we agreed on: an optional trailing argument passed down through the recursion, with Form supplying it. The stand-in is gone, the pairing rule is written down and tested, the scalar path uses the same comparison, and the docs, upgrade guide and changelog are updated. CI's lint and typecheck job passes on 03d9f5f0, so the type-check you couldn't run locally is covered.

I checked each scenario below with the ajv8 validator, against both the PR head and v7. Two things need to change before the details matter:

  1. The previous data should only decide the enum filter (comment on line 187). Right now the old schema resolved against the previous data is used for everything else as well: removing fields, the type check and the default/const swap. So Form now clears values that a nested conditional hides or retypes, and v7 keeps them. That follows from the shape I asked for in the go-ahead, not from anything you did wrong. I should have scoped it to the filter from the start.
  2. Without the previous data, behavior should match v7 exactly (comment on line 377). The round-3 gates are still used on that path, so formDataForNewOption and other direct callers see a change, and the changelog says they don't.

The other comments are smaller, and some of them go away once these two are done.

@charan-rathore

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed pass - all seven points are in.

What changed:

  • The old schema now resolves against the current data for field removal, the type check, the default/const swap and recursion, exactly as before; the previous data feeds only the enum filter decision.
  • Without previous data the filter always runs, matching v6 - the shape-based gates, conditionalResolvedUpstream and the eighth parameter are gone.
  • NO_VALUE keeps "no previous data passed" apart from "the previous value was undefined", threaded through the property and element recursion.
  • The filter decision compares the old schema resolved against the previous value with the new schema resolved against the current one, at both the property and the items level, and the raw items comparison is hoisted above the per-element loop.
  • New tests: the reorder/removal pin (values kept), a subtree missing from the previous data treated as a previous value of undefined, and the always-filter path when no previous data is passed.

One behavior change worth calling out: with previous data, a sibling flip that narrows an items enum through an ancestor if/then now keeps the value the previous data was offered (encoded in 'keeps items the previous data was offered when a sibling flip narrows the items enum'), because both sides arrive at the list carrying the same resolved items schema. Without previous data the filter always runs there, so the original #5250 report stays fixed. Happy to revisit if you'd rather an ancestor flip force the filter.

Verified locally: schema.test.ts 1006/1006 (the four new tests were red on the previous head, green now), the full @rjsf/utils suite 2672/2673 (the one failure is utcToLocal, which fails on a pristine checkout in this environment too), and core oneOf + LayoutMultiSchemaField 208/208. Lint and format ran through the repo's pre-commit hook; the type-checked lint variant OOMs in this sandbox, so I'm relying on CI for that pass, as before.

@heath-freenome heath-freenome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick turnaround. Most of round 4 landed cleanly: field removal, the type check and the default/const swap are back to v7's behavior; without previous data the filter always runs and the gates are gone; NO_VALUE separates "no previous data" from "previous value was undefined"; and the items comparison is hoisted.

CI is red, though. The build fails on Node 22, 24 and 26 with 18 core failures. All of them pass on v7 at the merge base:

  • 16 are the #5250 tests in packages/core/test/Form.errors.test.tsx ("nested inside an object" and "nested behind a $ref"). food stays 'worms' when it should become 'meat'.
  • 2 are the #1357/#2492 tests in packages/core/test/Form.behaviors.test.tsx.

They have two separate causes:

  1. An ancestor's conditional is invisible to the filter decision (comment on line 183). This is what brings #5250 back for every Form user. To answer your question directly: yes, an ancestor flip has to force the filter, because that is #5250.
  2. The array shortcut on line 355 treats an unchanged array as agreement even when the items schema changed.

Since the type-checked lint is left to CI, please also run packages/core's suite locally before pushing. The utils suite alone doesn't exercise Form.

The other comments are smaller, and two of them are tests that should flip once (1) is fixed.

Comment thread packages/utils/src/types.ts Resolved
Comment thread CHANGELOG-v7.md Resolved
@charan-rathore

Copy link
Copy Markdown
Contributor Author

Thanks @heath-freenome - all seven points are in bfaa725:

  • The old schema now resolves against the current data for removal, type and default handling (v5 parity), and a separate chain resolved against the previous data feeds only the enum filter decision. Without previous data the filter always runs; NO_VALUE keeps "no previous data" apart from "previous value undefined".
  • The array shortcut is guarded on identical raw items schemas and reads the old side; the comparison only runs when enum values exist and an item would actually drop. The invalid-enum replacement is also computed before any comparison now.
  • Flip test reverted to expecting ['a']; the moved-row test now expects v cleared (it falls back to the only offered option 'q'), with the mock stubs extended so the filter-chain resolutions return false instead of defaulting to true. Added a pin for a reorder where both rows have previous elements and no value drops.
  • types.ts JSDoc and a @rjsf/core changelog entry updated.

Verified locally before pushing: the failures you listed reproduce on the pre-fix source (8 tests red in Form.errors "nested inside an object" + 1 in Form.behaviors "should remove enum values in array when dependency switches"), and with the fix the full packages/utils suite passes 2673/2674 (the one failure is utcToLocal, which fails on main here too - environment timezone) and the full packages/core suite passes 4346/4346.

@heath-freenome heath-freenome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the separate previous-data chain fixes the round-5 regression. I had it checked at a4b8b6c8 with the real AJV validator:

  • #5250 through Form: the stale value is cleared, as on v7, for every variant I tried: items if/then inline and behind a $ref, an if/then on a parent object narrowing a list, a root if/then switching a $ref, root dependencies with oneOf, additionalProperties with if/then, and a row's if/then narrowing a nested list.
  • #5451: editing a sibling now keeps list: [null, null] where v7 drops it to [].
  • Suites: core passes 4346/4346 and utils 2674/2674 with coverage thresholds. CI is green.

Two things before merge:

  1. The @rjsf/core changelog entry went into the 6.x changelog (comment on CHANGELOG.md line 25).
  2. No Form test covers the #5451 fix (comment on Form.tsx line 826).

The other three comments are smaller: an extra resolve on every call, a limitation of oldData that should be documented, and a doc nit.

Comment thread CHANGELOG.md Resolved
Comment thread packages/core/src/components/Form.tsx Resolved
@charan-rathore

Copy link
Copy Markdown
Contributor Author

Thanks, all five are in f4e4509:

  • Changelog: the entry moved to CHANGELOG-v7.md as the last @rjsf/core bullet, reworded from v7 - Form passing its previous formData, the sibling-edit case (sanitizeDataForNewSchema() drops the empty minItems placeholders of a scalar enum array, so any change in a form with a conditional empties the list #5451) and the flipped-conditional case (A nested dependencies branch switch never sanitizes, so a narrowed select keeps an invalid value #5250), and "matching v6" rather than v5. Nothing about the intermediate state of this PR.
  • Form test: added under the schema-dependencies block with the real validator - a root allOf if/then on a sibling field, a list with minItems: 2 and an items enum; a sibling edit keeps list: [null, null]. It goes red in all 8 describeRepeated variants when the current?.formData argument is removed and green with it, so a later refactor that drops the argument fails CI.
  • The extra resolve: the filter chain now resolves on first need (a child's lookup, the scalar replacement, or the array filter), memoized per call, so a position that never reaches an enum check no longer pays for the resolve. One call-order-coupled utils mock was re-keyed to the new call count; its behavior assertion is unchanged.
  • The oldData limitation is documented in utility-functions.md, types.ts and createSchemaUtils.ts: $refs on both sides resolve against the one rootSchema, so pass oldData only when the root schema is unchanged, which is how Form calls it.
  • The object-path doc paragraph now names the borrowed-position exception alongside the array-path one.

Suites on this commit: core 4354/4354, utils 2674/2674 with the 100% branch coverage threshold met, and tsc --noEmit clean.

@charan-rathore

Copy link
Copy Markdown
Contributor Author

Rebased onto current v7 (af8bf31) after #5459 and the Form function-component rewrite landed. The conflict was the changelog bullets and the Form call site; the previous-formData argument now goes through formState.ts in the new architecture, with everything else from the rewrite kept. Re-verified on this box: the #5451 Form test still goes red in all 8 variants without the argument and green with it, core 4459/4459, utils 2740/2740 with the 100% branch coverage threshold met.

@heath-freenome

Copy link
Copy Markdown
Member

@charan-rathore you'll have to rebase again and fix the size limit issue

@charan-rathore

Copy link
Copy Markdown
Contributor Author

@heath Rebased onto the latest v7 (3c5f2ba, which includes the Form rewrite from #5438) and fixed the size limit failure.

The @rjsf/utils (without dependencies) check was over the 24 kB budget by 5 bytes (24005 vs 24000), and the growth came from this PR's feature code rather than upstream drift. I trimmed it back with two no-behavior-change rewrites in sanitizeDataForNewSchema.ts:

  • the lazy old-schema resolver now memoizes with ??= instead of a boolean flag
  • the shouldReplace / shouldFilter temporaries are folded into their conditions, so the resolves still run lazily in exactly the same cases

That brings the check to 23992 bytes, under the budget with a few bytes of room. Verified with the repo's own tooling (full nx build + .github/size-limit), and the full utils suite stays green: 125 files / 2740 tests, 100% coverage on all four metrics, including the new branches.

@heath-freenome heath-freenome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the rebase and the size-limit trim. All five round-7 comments are addressed: the changelog entry is in CHANGELOG-v7.md, the Form test for #5451 is in, the chain resolves on first need, and the $ref limit is documented.

I did another pass over ceb8ce18. Two comments matter before merge:

  1. Form doesn't apply the oldData precondition the new docs state (formState.ts line 556). When the schema prop changes so that a $ref target's enum narrows, a value the new enum rejects is now kept. Before this PR it was cleared.
  2. The lazy resolve only covers scalar leaves. Every array, and every object or array child, still resolves the previous-data chain up front (line 333 and line 247).

Line 286 is an inconsistency: the scalar path and the array path treat a select over object constants differently. The rest are cleanups. Two of them, on lines 236 and 245, delete code. That should free some room under the size limit, which item 2's fix may need. Line 400 is a design question you're free to decline.

@charan-rathore

Copy link
Copy Markdown
Contributor Author

All eight addressed in 34e5ee3, except line 400 which I'm declining (reasoning below).

1. oldData across a root schema swap (formState.ts:556) - confirmed, and the one-liner isn't enough on its own. areSchemaUtilsReused compares the previous state's utils against the newly constructed ones, but the swap already stores the new schema utils in state (with shouldSanitize: false), so by the time the next edit runs the sanitize pass, the comparison comes out equal and the stale data still goes through. Instead I added a formDataUtils provenance marker to the form state: it records which schema utils the current form data actually settled under (set after construction and after any sanitize, cleared on a swap that didn't sanitize), and the sanitize call now passes current?.formData only while schemaUtils === current?.formDataUtils. The new Form test swaps the schema prop to narrow a $ref target's enum, then edits a sibling. On the previous head the narrowed-out value survived; now it's replaced with the only enum option, which matches the pre-PR behavior I verified against the v7 base. One detail: the test's schema carries a nested conditional so the sanitize pass actually fires post-swap; without one, retrieveSchema returns the shared deep-equal schema and no pass runs at all.

2. Lazy resolve for arrays and container children (:333) - done. The chain is now a getter all the way down: array frames resolve the previous items schema through a memoized getter, and each object/array child receives a getter (parent getter plus key/index) instead of a resolved schema, so the resolve runs only when a scalar replacement or the filter actually needs it.

3. Object-constant selects (:286) - agreed, added the isWholeValueSelect exemption to the scalar always-replace condition, with a test showing the property path now drops { id: 3 } the same way the items path does.

4. Per-item filter (:400) - I'd rather leave this one. It re-opens the per-array decision 0fe7418 settled on, and the two behaviors it buys (placeholders surviving a widening enum, dropping the data-equality shortcut) don't affect any filed bug I can find. If you want it as a follow-up PR after this lands, I'm happy to pick it up there.

5. oldIsBorrowed (:236) - deleted. A borrowed child is now just called with an undefined getter; both readers ended the same way as oldSchemaPrev === undefined anyway, and grandchildren inherit the undefined getter for free.

6. NO_VALUE (:245) - dropped from oldData. Plain oldData?.[key] / oldData?.[index] / oldData everywhere; the getter being undefined is what carries "no previous data" now. The JSDoc paragraph went with it.

7. Single-pass filter (:393) - done: filter once, run the schema comparison only when the filtered array is shorter.

8. Comment style (:171) - rewritten to state the reason without the round-by-round history.

Suites: utils 125 files / 2741 tests with 100% statement/branch/function/line coverage, core 47 files / 4467 tests. Size: @rjsf/utils own-code is at 23,963 bytes under the 24 kB limit, so the cleanups covered item 2's growth with a little to spare.

@heath-freenome heath-freenome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. 34e5ee3 works through round 8: the formDataUtils marker, resolving the previous-data chain on first need for arrays and children, the whole-value select exemption on the scalar path, and dropping oldIsBorrowed, NO_VALUE and the double scan. I've resolved those threads, along with the earlier ones the branch now covers. The per-item question on line 400 is still open. It's non-blocking.

Before merge: the marker can say data was checked under the current schema when it wasn't, and then a stale value survives:

  • Line 602: after a schema swap, any edit that doesn't sanitize sets the marker again.
  • Line 1068: the marker is carried through commits that changed the data without sanitizing it.

Line 826 repeats the marker rule, and line 572 has a question about what the marker is keyed on.

I traced these by reading the code. I haven't run them.

@charan-rathore

Copy link
Copy Markdown
Contributor Author

All four addressed in 6d82dbd2. Your traces were right; I reproduced each one as a failing Form test before changing anything.

Line 602 - re-armed by a non-sanitizing edit. Confirmed with your exact scenario: swap narrows the $ref enum, an edit under a top-level if that stays false sanitizes nothing and re-set the marker, and the flip after it kept color: 'b' for good. The ?? schemaUtils fallback is gone: the marker now falls back to the utilities only on construction, never on a carried undefined. Test: "should not re-settle the data on a non-sanitizing edit after a swap" (red before, green after).

Line 1068 - carried through an unsanitized change. Confirmed with your pet example, including the declined array write: after the row add flips the then, the next sanitize got the post-flip data as oldData and kept 'g' (red), where v7 rejects it. I took your first option: a pass where mayNeedSanitizing held and no sanitize ran clears the marker, and deriveControlledState drops it whenever the parent's pushed value differs from the committed one (deep-equal pushes keep their shared reference, so only real changes clear it). The next sanitize then filters without oldData, which replaces 'g' with 'r' (green).

Line 826 - one rule, one place. Both copies now call a small settledFormDataSchema(current, rootSchema, sanitizeRan, sawUnsanitizedChange) helper.

Line 572 - keyed on the root schema. No reason to keep it on the instance; your point about inline validator/customMergeAllOf was real. A form re-rendered with a fresh inline validator lost the marker every render, and the following sanitize ran without oldData - I watched it empty a [null, null] minItems: 2 list whose items schema never changed, which is #5451 back for those forms. The marker is now formDataSchema, the root schema the data last settled under, compared by identity and shared through replaceEqualDeep so a parent rebuilding an equal schema object keeps the reference too. Test: "should keep prior data available when only the validator instance changed" (red before, green after).

The round-8 test is updated to cover the re-arm path as well. Suites: core 47 files / 4491 tests, utils 125 files / 2741 tests at 100% statement/branch/function/line coverage, and @rjsf/utils own-code holds at 23,963 bytes under the 24 kB limit (the whole change is in core). One honest caveat: my local box cannot run the repo-wide oxlint --type-check (the type checker is OOM-killed here), so I type-check the touched files individually; CI is the full-lint authority.

@heath-freenome heath-freenome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for turning this around quickly, and for writing a failing test for each round-9 comment first. Lines 602, 826 and 572 look fixed to me.

Before merge: the line-1068 fix needs another pass, and that one is on me. The first option I suggested clears the marker on ordinary edits: adding a row, a parent passing the form's own edit back, and reset(). Each time, the #5451 data loss comes back. The inline comment on settledFormDataSchema has the three sequences and a different approach. I confirmed all three by running throwaway Form tests against 6d82dbd. The other two comments come from reading the code.

On line 400: fair point, 0fe7418 settled that, and a follow-up PR is fine. I've resolved that thread.

@charan-rathore

Copy link
Copy Markdown
Contributor Author

Round 10 is up, taking your second option.

The settled snapshot. FormState now carries settledFormData next to formDataSchema: the data as of the last settle, recorded on construction and on every pass that sanitized. The sanitize call passes that snapshot as oldData instead of current.formData, so a declined sanitize, a pushed parent value and a reset all leave it alone and none of those paths needs its own clearing rule — sawUnsanitizedChange and the deriveControlledState data-guard are gone, and a schema swap still drops it through the root-match condition. #5250 stays covered because the snapshot is the data from before the flip, and "should not treat data changed by a declined sanitize as checked" still passes without the clearing it was written against.

Your three sequences are Form tests now, on the #5451 schema starting from { list: [null, null] }:

  • should keep placeholders through two sibling keystrokes (parent-owned)
  • should keep placeholders through a declined sanitize and a sibling edit
  • should keep placeholders through a reset and a sibling edit

All three failed against 6d82dbd in exactly the pattern you described — the first in the parent-owned variant only, the second in every variant, the third in the self-owned variant only — and pass now.

The re-resolve flag. sanitizeDataForNewSchema takes an internal oldSchemaResolvedForOldData argument; when set, the root frame's filter chain uses oldSchema directly instead of resolving it against oldData again. Form sets it exactly when the snapshot is the data retrievedSchema was resolved from (settledFormData === current.formData), so the common settled case pays no root re-resolve, and the edited-snapshot case still resolves against the older data, which is what the comparison needs. There is a utils test asserting the pre-resolved path matches the resolving path.

The double walk is gone with the rewrite: the pass shares the root once into sharedRoot and hands it to the helper, which no longer walks on carry.

And no apology needed — the first option was the reasonable read of a two-state marker, and your running the sequences caught what my analysis didn't. Thanks for that.

@heath-freenome heath-freenome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 11. ed29aad fixed the three sequences from my round-10 comment, and I've resolved those threads. I ran the review again on 99229b1. I confirmed two regressions against v7 with throwaway Form tests, run on this head and on v7 3c5f2ba; both come from the settled-snapshot design. Two more items are reasoned from the code: the array pairing (not run) and the scalar re-resolve. The other four are API, docs and cleanup.

The first one is again a gap in the option I proposed rather than in your implementation of it. I paired the snapshot with the committed data's resolved schema without noticing that the root's conditionals are already merged into it.

Comment thread packages/utils/src/types.ts Resolved
@charan-rathore

Copy link
Copy Markdown
Contributor Author

All eight threads are in the pushed head (aad44b9, plus 107bf4c which merges v7's #5464 and resolves the overlap in formState.ts):

  • Must-fix 1 (top-level conditional never seen): the settling pass now also stores the schema it resolved (settledRetrievedSchema), and that is what the previous-data side uses, passed as the new resolvedOldSchema parameter instead of re-resolving current.retrievedSchema. Your A nested dependencies branch switch never sanitizes, so a narrowed select keeps an invalid value #5250-regression schema is a Form test; it kept color: 'g' before the fix and resets to 'r' after.
  • Must-fix 2 (parent-owned snapshot never moves): when the parent pushes back the exact value the edit path proposed, the form takes it as the new settled snapshot, so the controlled-form case matches self-owned. Your AcceptingParent scenario is a Form test (now gives color: 'r').
  • Declined remove/reorder mispairing: the array path pairs each row against its own prior position rather than a shifted neighbor's, so a declined remove no longer feeds a row the previous value of a different row. Your [{kind, tags}] scenario is the third new Form test; [null, null] survives.
  • The flag is gone from the public surface: resolvedOldSchema is a schema the caller passes in, documented in the JSDoc, utility-functions.md and the upgrade-guide table.
  • Docs: "passes the data as it last settled under the current root schema" in types.ts, createSchemaUtils, the docs and the changelog.
  • Perf shortcut: adopted, with the raw keyed schema equality plus deepEquals(oldData?.[key], formValue) gate, so a kept out-of-enum value no longer pays a resolve per pass.
  • Nit: the ??= wrap is gone; the items getter is the one-line lazy form you wrote.
  • Marker lifetime: a marker whose root no longer matches is dropped, and an empty marker still fails hasSettledData.

The three new Form tests live in packages/core/test/Form.settledSnapshot.test.tsx, red before and green after. Full suites on the merged head: core 4831/4831, utils 2741/2742 (the one failure is the pre-existing utcToLocal timezone test), tsc and lint clean.

@charan-rathore

Copy link
Copy Markdown
Contributor Author

@heath-freenome On the unsettled-snapshot thread: all three paths are fixed in 8ea08e02.

  1. Live validation / key move (formModel.ts:418). The live and move branches of withOwnedErrors now commit next.proposedFormData, as the branch below does.
  2. Stacked edits (formModel.ts:425). The stacked branch now commits next.proposedFormData, the object propose(next) actually sends, and the errors come from applyChangeToErrors(base, edit, props.extraErrors) again instead of a full applyChange.
  3. Cleared or omitted data (formState.ts:1627). The marker is taken from newFormData after the copyAlongPath and omitExtraData copies, so the committed proposal is the value the parent receives.

Tests in Form.settledSnapshot.test.tsx: the stacked-edit and cleared-leaf paths each have a test that is red on the old head and green with the fix. One honesty note on path 1: I implemented the fix and wrote the live-validate test, but I could not construct a sequence that fails on the old head, so that test passes both ways. Your trace says the branch never commits, and the fix is small and matches the branch below, so I kept both the fix and the test, but the test does not pin a reproduced regression.

@charan-rathore

Copy link
Copy Markdown
Contributor Author

@heath-freenome On the array-pairing thread: took your preference in 4d09cc90. A row whose previous value cannot be trusted (the lengths differ, or there is no previous array at that position) gets no previous data and no filter-chain getter, so its filter runs as it did in v7. This undoes the self-pair and the length check from aad44b9.

Your three sequences under the new rule:

  1. Length differs. The flip inside a row is no longer hidden: the row resolves on its own and the stale value is filtered.
  2. Same-length reorder. Still pairs by position and can still mis-pair; as you said, no rule based on position can detect it. Left as is and documented in the code comment.
  3. No previous array. Rows get no previous data, so the old side is never resolved against undefined and the required-less if artifact is gone.

Test changes: the insert test from 0d0ca81 is re-pinned to the v7 outcome (the moved row's stale value is replaced, by the enum's only option here), the declined-remove case is back to the v7 outcome ([{ kind: 'y', tags: [] }]), and Form.settledSnapshot.test.tsx has the three Form tests you asked for: insert-flip, same-length reorder, and no-previous-array flip, each pinned to the outcome the new rule produces.

@charan-rathore

Copy link
Copy Markdown
Contributor Author

Round 13 is up at b5fe05e1. Commits since the round-12 review:

  • 5d9652f8 nits: oxfmt the upgrade-guide table, changelog entry moved to the end of the @rjsf/core list, and the new tests switched from fireEvent to userEvent.
  • c26fd675 an accepted proposal settles only under the root it was sanitized with (replaceEqualDeep against schemaUtils.getRootSchema()), with a root-swap test red-then-green.
  • 8ea08e02 the three unsettled snapshot paths, details in the thread reply above.
  • 4d09cc90 the array-row pairing rule, details in the thread reply above.
  • b5fe05e1 bump the @rjsf/utils own-code size budget to 24.1 kB.

Local checks:

  • utils suite: 2747 passed, 1 failed in utcToLocal.test.ts, which fails on this machine on a clean tree as well (timezone environment).
  • utils coverage gate: 100% on all four thresholds, including the sanitizeDataForNewSchema.ts branch that was missed last round.
  • core suite: 4884 passed.
  • size-limit: @rjsf/core 30.98 kB and the Form canary 30.67 kB, both under 31 kB; @rjsf/utils installed 29.67 kB under 34 kB; utils own code 24.07 kB, which was 72 B over the 24 kB budget, hence the bump.
  • cs-check clean.

@heath-freenome heath-freenome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 13. Thanks for working through round 12. The nits are fixed, and I've resolved those three threads. c26fd675, 8ea08e02 and 4d09cc90 do what round 12 asked, but two of them open new holes. I've replied in the formState.ts:1254, :858 and sanitizeDataForNewSchema.ts:386 threads.

CI is still red on b5fe05e1:

  • checks: lint, which is also the typecheck, fails with 11 errors (inline on the test file). The round-13 summary didn't list lint among the local checks.
  • build, on all three Node versions: @rjsf/utils branch coverage is still 99.96%, at the same statement as last round (inline).
  • size passes with the 24.1 kB budget.

Two of the thread replies are about my own round-12 requests. The :1254 reply covers a gap in the check c26fd675 built from my wording. The :386 reply goes back on the array rule I preferred, which 4d09cc90 adopted; sorry for the churn on that one.

The reset comment at formState.ts:851 questions a choice ed29aad7a made on purpose, so it's your call.

All of this is traced from the code and the CI logs. I didn't run any tests.

Comment thread packages/core/src/components/Form.tsx Resolved

@heath-freenome heath-freenome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 14. Thanks: d665b879, 5108b668, 823a368d, b6583669, 32801c7b and 4df42a23 close out most of round 13, and I've resolved those eight threads. @rjsf/utils coverage is 100% when I run it locally.

CI hasn't run on ddb48053, because the workflows are waiting for approval. Running pnpm run lint locally fails with two TS2741 errors from the new state member (inline on formModel.ts).

Two of the new fixes need more work. I've replied in the open threads:

  • formState.ts:869 (the reset/push thread): a #5250 regression I reproduced. After a parent push the form doesn't take as its own proposal, flipping back to the snapshot's branch keeps values that branch rejects. v7 without this PR clears them.
  • sanitizeDataForNewSchema.ts:386 (row pairing): e3cc5729 only reaches self-owned forms, and the move can line rows up wrongly after a change it wasn't told about.

There are also inline notes on docs for oldDataForPairing and a proposal that never clears, plus a follow-up on the K nit in its thread. Only finding 1 and the lint errors were run; everything else is traced from the code.

Comment thread packages/utils/src/types.ts Resolved
@charan-rathore

Copy link
Copy Markdown
Contributor Author

The four open threads, all verified locally (full core suite 4952 green, utils suite 2798 green with the 100% branch gate, type-checking lint clean):

Reset keeps a stale snapshot (formState.ts:869): your trace was right for the code you reviewed. It is fixed in b596319: a reset's derivation passes no current state into settledFormDataState, so the restored initial data is recorded as the snapshot the way the first render does. The Form test at Form.settledSnapshot.test.tsx:85 runs exactly your sequence (if/then on cond, enum pick; set cond=y, reset, set cond=y again) and expects pick cleared. I re-verified the discrimination: the sequence goes red with the reset settle taken out and green with it back. Pushes I left as they are: a pushed value carries no signal of where it came from, so it settles only when it accepts the edit path's outstanding proposal unchanged, and an honest proposal restores the marker even after the parent changed the schema once.

One helper for the constraint check (sanitizeDataForNewSchema.ts:320): done in 3fb8ac2. constraintMayHaveChanged() takes the previous raw schema, the new raw schema, both values and the resolved new schema: equal raw schemas and equal values answer without resolving, and anything else resolves the previous side against the previous value and compares it against the resolved new schema. The array filter's shortcut folded into it entirely. The scalar path keeps one proof ahead of the helper: when the chain's root IS the frame's old schema, the raw comparison stands in for the chain, which skips resolving the previous root that a pending enum replacement would otherwise pay on every pass. The comparison itself can no longer drift.

The double walk (formState.ts:753): done in 5e123dc where it was cheap. deriveFormData passes the sharing answer it already computed for hasSettledData in as rootMatches, so a schema swap walks the root once. In deriveControlledState the acceptedProposal walk is against the proposal's own root, not the marker's, so there is no second walk to remove there; an accepted proposal settles without reading the marker at all.

The reversed rule (sanitizeDataForNewSchema.ts:386): no apology needed, the code already works the way you describe. The form carries two views of the settled data: settledFormData, as it settled, which the old-schema side reads so a nested conditional resolves pre-flip; and settledFormDataForPairing, moved by each announced container write through the same AnnouncedMove the errors use, which the array path pairs rows against. An inserted index holds no previous value, a removed row takes its snapshot with it, a reorder follows its item, and the length check stays as the net. Your two points: settledRetrievedSchema was resolved for the snapshot itself, which never moves, so the two still match; and the pairing view is parent-owned (IS_OWNED_BY_FORM lists it false), so it travels with the proposal the way the marker does. The add-row-then-edit-sibling test is at Form.settledSnapshot.test.tsx:566.

One honest note on the tests: the deep-equal-copy parent test goes red on the old acceptance condition, but the changed-schema-once parent test passes both ways. Under the old condition the marker drop still left the later edits filtering correctly in that sequence, so it pins the behavior without discriminating. You caught the same shape on the live test, so I would rather say it than have you find it.

Size: this PR raises the core installed budget to 31.5 kB (096b57a); utils needs no bump, since v7 already carries 25 kB.

@heath-freenome heath-freenome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 15 on 5e123dc3. Lint and typecheck are clean, @rjsf/utils coverage is 100% and CI is green, thanks. I resolved two threads: the double walk, and the IS_OWNED_BY_FORM entry.

Still open from round 14, with the code unchanged:

  • The oldDataForPairing docs (types.ts:2039).
  • The getter that forces the parent's resolve below the root (:346 thread).
  • The proposal that is never cleared (formState.ts:1315).

Findings 1, 3 and 4 have follow-ups in their threads. I ran 1 and 3.

I ran both new gaps below on this head. Both fail the same way on the v7 base, so they're #5451 cases this PR still misses, not regressions.

On the approach (not a request to change it). The fix now carries six FormState members, a proposal-acceptance check and a replay of row moves, all to decide whether an enum filter runs. Each open item comes from a data path that changes the data without settling the snapshot: a parent push, a container write in a parent-owned form, an added row, a schema swap. A narrower fix would keep null/undefined placeholders inside the filter itself. That would reverse 7c754ab25 and every round built on it, so I'm not asking for it. If you keep this approach, please list in the PR body which paths settle the snapshot and which don't. That would make the rest of these easier to check.

Comment thread CHANGELOG-v7.md Resolved

@heath-freenome heath-freenome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick turnaround. Everything from round 15 is in, and I've resolved all 10 open threads. At 152e5358, lint, cs-check and @rjsf/utils coverage (100%) pass, and my repros for the flip back, the parent-owned remove and the added row all pass.

The moved pairing view has three gaps I ran and one I only traced, plus two doc nits. Each is inline below. I ran each test against both this branch and v7. Only the third (push, then remove) is a regression: v7 filters the pushed value, and this branch keeps it. The root-array and declined-reorder cases fail on v7 too, so they're places where #5451 isn't fixed yet.

Also, CHANGELOG-v7.md now conflicts with v7. When you merge it, please keep both bullets last in their lists.

@heath-freenome

Copy link
Copy Markdown
Member

@charan-rathore can we focus on getting this PR merged before you do anything new?

@charan-rathore

Copy link
Copy Markdown
Contributor Author

Yes. This PR is my only active work right now. Round 17 covers all three runnable gaps plus the two doc nits: a container write now carries the pairing view it moved as pending state until the parent answers that write, and the sanitize call marks a frame with no previous array explicitly so a declined write can no longer revive a dropped key's settled value. The three new tests reproduce your probes verbatim. Pinned suites pass (21/21 settled-snapshot, 1012/1012 utils schema); I'm running the full core suite before I push.

@charan-rathore

Copy link
Copy Markdown
Contributor Author

Round 17 is up at 3ffe489d, rebased onto current v7 (a054f323; the changelog keeps both bullet sets, ours last). All four gaps and both doc nits are answered inline above.

Local gates: pinned suites pass (21/21 settled-snapshot, 1012/1012 utils schema), the full core suite passes (49 files, 4959 tests), oxfmt clean, and ty fingerprints are identical base/head. One disclosure: oxlint --type-check would not complete on my box - the type-checker was OOM-killed on every attempt (whole repo and per-package), so the CI run of that gate is the one of record here.

@charan-rathore

Copy link
Copy Markdown
Contributor Author

Amend note for the re-push: the size check failed on the squash - the Form canary measured 31.02 kB against the 31 kB budget. This push trims the round-17 code back under it: the pending members shorten to pendingView/pendingData, the two root-path writes share one writeAtPath helper, and the conditional spreads go falsy (: 0) instead of : {}. No behavior change; the pinned suites still pass (settled snapshot 21/21) and the canary measures 30.99 kB with the repo's own size-limit config run locally.

@heath-freenome heath-freenome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick turnaround. The declined reorder, the root-array reorder and both doc nits are fixed, and I've resolved those threads. My round-16 repros pass, the settled-snapshot suite passes, and utils coverage is 100%.

Two things block approval:

  • checks fails on 5df3f53f with a type error from the size amend (inline at formState.ts:529).
  • The length-mismatch regression is fixed for nested arrays but not for an array at the document root (my reply on the round-16 thread).

The two-writes follow-on (my reply on the stacked-write thread) and the two gaps below aren't blocking; both gaps behave the same on v7. The two nits are optional, though I'd take the readable version plus a 31.5 kB Form canary over the size trims.

…h container writes (rjsf-team#5460)

The sanitize pass filters an array's items against the items enum only
when the items schema itself changed, when either side was resolved
against the current data into a different shape, for selects over
object or array constants, and for properties the new schema
introduces - so editing an unrelated field no longer deletes entered
values such as unfilled minItems placeholders, fixing rjsf-team#5451.

Container writes carry a pairing view of the settled data so a moved
row follows its item to its new index, and hold that view as pending
state until the parent answers the write: an out-of-order or declined
push can no longer re-pair a row against a sibling's item, and a frame
with no previous array is marked explicitly so a deliberately dropped
key's settled value is not revived.

Fixes rjsf-team#5451

Signed-off-by: Charan Rathore <[email protected]>
@charan-rathore

Copy link
Copy Markdown
Contributor Author

Round 18 is up at 1e47db99, answering all seven notes inline above: the root-path regression is fixed with your sanitize-call guard and pinned by a root-level variant of the push-then-remove repro (watched it fail on the previous head with ['a', 'a'] kept, passing now with []); the checks type fix from cebf4828 is confirmed; the changelog covers the augmenting-parent case next to the schema-swap note; the size trims are reverted to the readable version with the Form canary raised to 31.5 kB; and the NO_PREVIOUS_VALUE doc comment is reordered and completed. The double-write trace and the optional-array case are both follow-up shaped, as you marked them; I'll file the two issues once this lands.

Local gates: pinned suites 22/22 settled-snapshot and 1012/1012 utils schema, the full core suite passes (49 files, 4970 tests), tsc clean on both lib configs, oxfmt clean, and the repo's own size-limit measures the Form canary at 31.05 kB against the new budget. The same disclosure as before: oxlint --type-check OOMs on this box, so that gate is CI's call; watching the run.

@heath-freenome heath-freenome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick turnaround. Both blockers are fixed at 1e47db99: checks is green, and my root-level push-then-remove repro now ends with tags: [], as on v7. All 22 settled-snapshot tests pass, and so does the rest of CI. The readable version of the pending-pairing code is back, with the Form canary at 31.5 kB.

Approving. The two follow-ups you offered to file once this lands (two container writes in one event, and an optional array with no default) are fine as separate issues. The three inline notes below are small and non-blocking.

@heath-freenome
heath-freenome merged commit b5695a7 into rjsf-team:v7 Oct 12, 2026
7 checks passed
jimmycallin added a commit to jimmycallin/react-jsonschema-form that referenced this pull request Oct 14, 2026
Resolving the changelog conflict of the peer floor commit took the
branch's side whole, which dropped the entries v7 had added meanwhile
(rjsf-team#5460, rjsf-team#5474, rjsf-team#5510, rjsf-team#5484, rjsf-team#5488, rjsf-team#5508). The rjsf-team#5460 entry loses its
last sentence: a parent that adds to the data it stores no longer keeps
the snapshot from settling, since every edit settles it in the form.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
jimmycallin added a commit to jimmycallin/react-jsonschema-form that referenced this pull request Oct 16, 2026
Resolving the changelog conflict of the peer floor commit took the
branch's side whole, which dropped the entries v7 had added meanwhile
(rjsf-team#5460, rjsf-team#5474, rjsf-team#5510, rjsf-team#5484, rjsf-team#5488, rjsf-team#5508). The rjsf-team#5460 entry loses its
last sentence: a parent that adds to the data it stores no longer keeps
the snapshot from settling, since every edit settles it in the form.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
jimmycallin added a commit to jimmycallin/react-jsonschema-form that referenced this pull request Oct 16, 2026
Resolving the changelog conflict of the peer floor commit took the
branch's side whole, which dropped the entries v7 had added meanwhile
(rjsf-team#5460, rjsf-team#5474, rjsf-team#5510, rjsf-team#5484, rjsf-team#5488, rjsf-team#5508). The rjsf-team#5460 entry loses its
last sentence: a parent that adds to the data it stores no longer keeps
the snapshot from settling, since every edit settles it in the form.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
jimmycallin added a commit to jimmycallin/react-jsonschema-form that referenced this pull request Oct 16, 2026
Resolving the changelog conflict of the peer floor commit took the
branch's side whole, which dropped the entries v7 had added meanwhile
(rjsf-team#5460, rjsf-team#5474, rjsf-team#5510, rjsf-team#5484, rjsf-team#5488, rjsf-team#5508). The rjsf-team#5460 entry loses its
last sentence: a parent that adds to the data it stores no longer keeps
the snapshot from settling, since every edit settles it in the form.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
jimmycallin added a commit that referenced this pull request Oct 21, 2026
…5556)

* feat(core)!: let Form own its data and take formData only when it changes

Form has one data owner, itself. `formData` is the value it takes, filled in
with the schema's defaults, on mount and whenever it is passed a value it has
not seen: neither its own data, which a parent storing what `onChange`
reported passes back, nor the prop of the render before. `initialFormData` is
read on mount and on `reset()` only. Edits are applied and shown before
`onChange` is called, whatever the parent does with them; a parent refuses
one by setting the field back.

That removes the parent-owned mode and everything that served it: the
proposal held until the parent answered, the epoch it was dropped by, the
members owned per owner, the validation a blur owed the render that answered,
the controlled branches of change, blur, reset and the derivation, and the
three ownership warnings.

Without live validation, a change now clears the validator's errors of the
fields it replaced in `applyChange()` itself, for both seeds. That clearing
existed only as a side effect of the parent-owned derivation diffing the prop
against the previous one; a form seeded with `initialFormData` kept the
errors until the next validation. A change that moves array items is diffed
with the items where the move put them, so the errors that moved with them
stay, under every parent. A root array is diffed by index like a nested one.

The reporter that held callbacks while an `<Activity>` hid the form goes
too, with its three Effects: a callback is called when its operation happens,
hidden or not, and a handle kept past the unmount still works. The react
peer goes back to >=19, since the insertion Effect cleanup that needed 19.2
is gone.

`submit()` calls `requestSubmit()` at once instead of queuing until the
inputs show the data. Native constraint validation checks the inputs as
rendered, so an edit that fills a required input in the same handler is
blocked until React renders it, as in v6; the `CustomEvent('submit')` the
queue dispatched never reached React's handler and is deleted. The form
element is kept across the ref detach an `<Activity>` causes, so a hidden
form submits.

`commit()` takes the next state alone: the reapply guard served operations
issued from a validation callback, which the docs forbid. `applyChange()`
copies the containers along the change's path instead of structured-cloning
the whole value, which also stops a `File` or class instance in the data
from throwing or losing its prototype.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* docs: describe the form as the one owner of its data

The upgrade guide, the form props reference, the internals page and the
quickstart describe `formData` as the value the form takes when it is passed
one it has not seen, `initialFormData` as the seed, edits as applied before
they are reported, and `submit()` as a submit through the element at once.
The controlled-form rules, the hidden-form paragraph and the ownership
warnings are gone with the behaviour.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* refactor(core): drop what the one-owner contract left stranded

`MultiSchemaField` kept a record of the data its option switch sent so that
a switch whose data did not follow it, a parent declining it, could be put
back. The data always follows now; the record is a flag that keeps the
user's own switch from being re-matched against the data it adds.

The model's `Report` and `OperationProps` existed so an operation could not
report through the props it started with, since a report held for a hidden
form had to use later props. Reports are immediate, so an operation reads
`committedProps` and calls the callback itself; a field's report still goes
through `callWithDeferredThrow()`.

`FormState.edit`, a v6 flag that gated live validation on a prop change for a
form that was never handed data, goes: live validation runs for the data the
form holds whenever something the errors depend on changed.

`FormState` is no longer exported. It carries memo keys and bookkeeping, and
`IChangeEvent` is the public shape of what reaches a consumer.

`describeOwnerships` ran nine suites once self-owned and once under a parent
that stored every edit back. The second run only proved that passing the
form's own data back is not a replacement, which the ownership suite states
once; `describeRepeated` keeps the four extra-data variants.

`ObjectField`'s seed records stay as they were: a child's write does not
pass through the field, so the data is where a property's history is read,
whatever the owner. Only the comments that described a declined rename go.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* refactor(core)!: let container fields read the form's data instead of a view of it

`ArrayField` and `ObjectField` built their adds, removes, renames and
reorders from a view: the data they were rendered with, advanced by what
they had sent since, and vouched for by a context chain through every core
field that declared which child it had handed the form's own data. The
vouching existed so that a custom field handing a core field a transformed
view, a sorted copy say, kept to that view. The view layer is gone: a
container field reads the form's current value at its `fieldPath`, and a
custom field that wraps one has to pass `formData` through unchanged.

That removes `useFieldView`, `RawFormDataContext` and its eleven call sites,
and the `epoch` and `proposing()` the model kept so a field's record of a
view it sent ended at the right commit. `FormDataContext` keeps `readField`
and `sendMove`. `ArrayField` keeps its rows in a ref beside the keys that
render them, installed from an insertion Effect, so a second handler in one
event starts from the rows the first one sent; `ObjectField` reads the
rendered data through a ref outside a `Form`. Both read through refs rather
than closing over the render's data, so a handler keeps its identity across
edits and sibling rows are not re-rendered.

A custom field that passes the form's data on, which the component chain did
not vouch for, now composes edits in one event with the rest of the form; one
that keeps a draft or hands a transformed view no longer chains edits on it.
The tests for those wrappers are gone, and the custom-fields page and the
upgrade guide say what a wrapper may hand a container field.

Tests and helpers are reworded for the one owner: `Form.parents.test.tsx`,
`ParentLog`, `ParentProps`, and `reported` for what was `proposals`.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* docs: record the one-owner contract in the changelog and correct the core peer floor in the guide

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* chore(core): keep the react peer dependency floor at >=19.2

The one-owner change lowered the floor to >=19 because the insertion Effect
cleanup that needed 19.2 was gone. 19.2 is the oldest React RJSF supports, so
the floor stays where v7 has it. The changelog entry and the upgrade guide say
so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): fix what the review of the one-owner form found

A change that reaches a form after it unmounted is dropped, as in v6: a
draft a widget flushes from an Effect cleanup, a late timer or file read,
or `setFieldValue()` and `reset()` through a handle kept past the unmount.
Reported through the last render's `onChange`, it was stored as the data
of the form that replaced it. The form learns of the unmount from an
insertion Effect cleanup, which an `<Activity>` hiding it does not run, so
a hidden form goes on taking changes.

`committed()` keeps an edit made between a render and the form's insertion
Effect under a parent that stores edits, where the echo was read as a new
value and replaced it.

Without live validation, adding or copying an array item no longer clears
the array's own validator errors, which a remove and a reorder kept.

`reset()` reports the `extraErrors` it leaves on display instead of an
empty error list.

`submit()` and `focusOnError` compare against the classes of the form
element's own window, so they work for a form rendered into an iframe.

A root `formData` of `NaN` is recognised as seen through `Object.is`, where
it was taken again on every derivation.

`ArrayField` gives every slot of a sparse array a key and a row, where a
hole rendered no row and made Add throw.

The docs, the changelog and the doc comments say what the code does for
edits shown before `onChange`, a record that loads after mount, `submit()`
and `reset()`, and a form that has unmounted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): keep three v6 behaviours the one-owner form had dropped

An option switch that `onChange` answers by setting the field back returns
the `oneOf`/`anyOf` selector to the option the data fits, as v6 and v7 do.
The field again records the data its switch sent, so it can tell data that
followed the switch from data that did not; the flag that replaced the
record kept the chosen option whatever the next render brought, which left
the selector and the option's fields on a refused option.

A live-validated form that was never handed data is not validated because
a validation prop changed identity. The `edit` gate v6 and v7 have is back:
without it a `transformErrors` written inline showed the `required` errors
of an untouched form on the parent's next render.

An edit a consumer's function makes through the handle while an operation
runs, such as `setFieldValue()` from `customValidate` during
`validateForm()`, is kept. The operation runs once more on top of it, where
its result, computed from the data before the edit, used to be stored over
an edit that `onChange` had already reported.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor(core): share what the container fields read and send through, and drop what the rebase left unused

`useReadFieldData()` and `useSendMove()` take over the read of the form's
current data and the announced key move that ArrayField, ObjectField and
`useSendOptionSwitch()` each spelled out. `settledFormDataState()` drops its
`rootMatches` fallback, which no caller reaches since the caller shares the
root, and `applyReset()` and `applySubmit()` share `extraErrorsAlone()`.
`deriveState()` shares and records the `formData` prop in one place, which
the model's commit reuses, `withKeysMoved()` drops its overload, and
`ownedErrorsOf()` is `errorStateOf()`. ArrayField's confirmed rows say again
when they are needed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): pair rows against the settled data when the parent sets a reorder back

A formData the form takes that is not a copy of its own data resets the
pairing view to the data as it last settled, from before the container
writes since, as v7 did for a declined write (#5451). A parent setting a
reorder back otherwise had the next sibling edit pair each row with its
neighbour's previous value and drop its placeholders. The test that
covered this declined with the value the parent already held, which the
form now ignores as seen, so it sets the value back as a copy; the other
settled snapshot tests are renamed from proposals to edits.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): validate without reporting through a handle kept past the unmount

`validateForm()` and `validateFormWithFormData()` on a form that has
unmounted return their result without committing the errors or calling
`onError`, as a change or a `reset()` there is already dropped: the
callback is the last render's, and there is no form left to show what
it found.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: fold the owner-at-mount changelog entries into the one-owner entry

The v7 changelog described both the owner decided at mount and the
one-owner form that replaces it. The entries that only described the
former go, the one-owner entry takes over what still holds of them
(defaults without `onChange`, frozen `formData`, `submit()` after an
edit), and the others speak of a parent setting a change back rather
than declining a proposal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(core): read elements and the handle through helpers instead of non-null assertions

`elementOf()` joins `input()` and `handleOf()` in testUtils, failing the
test with a message where a `!` would only defer the failure.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor(core): diff a change only for errors to clear, and name what a pass is told

A change diffs the data it replaced only when there are validator errors
to clear, through a thunk as `reconcileErrors()` takes it, so a keystroke
in a form without them no longer pays for the diff and the error
rebuild. `FormState.edit` is `isDataPassed`, which is what it records,
and `deriveDataState()` takes it as a named option rather than a bare
`true`. `withKeysMoved()` checks for a removed item's missing key instead
of relying on `NaN` failing a comparison, `FieldChange` and `KeyMove` are
no longer exported, and `useKeyedFormData()` hands ArrayField the items of
its sent rows itself.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): keep the moved pairing view where a value the form takes holds its data

A `formData` the form takes is paired node by node: where it holds what
the form's data does, it keeps the pairing view the container writes
moved, and elsewhere it is paired against the data as it last settled.
A parent that stores each edit with a field of its own, such as a
timestamp, passed a value that was never the form's data, so a reorder
lost its moves and the next sibling edit dropped the rows' placeholders
(#5451). The pairing view is typed `unknown`, which it is, so moving it
needs no cast.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(core): read elements and handles through the helpers in the rest of the rewritten tests

The tests this PR rewrote most held 68 more non-null assertions on lines
it had not touched; `elementOf()`, `input()` and `handleOf()` replace
them, so each file reads its elements one way.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: restore the v7 changelog entries the rebase onto v7 dropped

Resolving the changelog conflict of the peer floor commit took the
branch's side whole, which dropped the entries v7 had added meanwhile
(#5460, #5474, #5510, #5484, #5488, #5508). The #5460 entry loses its
last sentence: a parent that adds to the data it stores no longer keeps
the snapshot from settling, since every edit settles it in the form.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(core)!: seed the form from formData on mount and reset only, as initialFormData

`formData` is another name for the seed, taken over `initialFormData`
when both are passed: read on mount and on `reset()`, and ignored after
that, as React's uncontrolled inputs read `defaultValue`. Data the form
reported changes nothing when it is passed back, and any other value
warns once in development and points at a `key` or `setFieldValue('',
data)`. The adoption path goes with it: `FormState.formDataProp`, the
seen-value check and the pairing of an adopted value.

A container written with no move announced, as `setFieldValue()` puts a
reorder back, now pairs the rows it changed against the data as it last
settled, where it kept the view the reorder moved (#5451).

The tests that replaced the data by passing a new `formData` do so
through `setFieldValue('', data)` or a `key`; those of the contract
itself assert the new one. The playground remounts its forms when a
sample loads or the JSON editor replaces the data, and the docs describe
the seed, the `key` and `setFieldValue()`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor(core): make ArrayField's row keys without mutating anything while rendering

Rows made while rendering are keyed from a generation held in state and their index, and ordered as the items are; rows a handler adds take a key from a per-field count only handlers move, ordered after every current row. Rendering is pure, so StrictMode's second render keys the rows alike, and a row added after a remove never takes a key a row has had.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(core): refuse or rewrite an edit in a pure transformChange prop

`transformChange(next, previous)` decides what an edit leaves the form
with before the form stores, validates and reports it, so a parent that
refuses or normalizes an edit no longer calls `setFieldValue()` from
`onChange` and gets a nested report. It runs inside the model's
re-run of an operation, so it must be pure; a value it changes is
written over the whole form, which re-derives defaults, clears the
errors of the values it replaced and pairs the rows of a refused
reorder against the settled data. The guide's refusal section, the
prop reference and the changelog describe it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor(core)!: hand commits to the store from layout Effects and treat a hidden form as unmounted

The form no longer uses insertion Effects, which React reserves for
CSS-in-JS. Each commit hands the model its props and rendered state from
a layout Effect, and the model publishes the state the render derived,
so the store's snapshot is the state the form shows; the render derives
it with `useMemo` instead of setting state while rendering. A prop
change that changes the form's state takes a second commit to publish
it, which renders no field. A field's layout Effect, which runs before
the form's, sees the previous props in the commit that renders new ones.

A form an `<Activity>` hides is detached as an unmounted one is, the
way React asks hidden content to be treated: it drops changes, `reset()`
and `submit()`, and its validation methods return their result without
reporting. `submit()` after an edit React has yet to render waits for
the commit that renders it, so native constraint validation checks the
inputs as they show the edit, and the guide's Effect for that is gone.
ArrayField and ObjectField keep their latest rows and data from layout
Effects too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(utils,core)!: fill a null schema's value in as a default instead of from NullField's mount Effect

`computeDefaults()` gives a missing value of a `type: 'null'` schema the
one value it allows, `null`, except for the `anyOf`/`oneOf` option a
field renders, whose `null` option renders no field. `NullField` renders
nothing and no longer calls `onChange` from an Effect as it mounts, which
React asks components not to do; the submitted data is the same, and the
form holds the `null` from its first render without a report.
`getDefaultFormState()`'s return type, and the public
`SchemaUtilsType.getDefaultFormState()`'s, include `null`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(chakra-ui): let NumberInput show its value without writing the input from an Effect

`NumberInputRoot` wrote `props.value` into its input element from an
Effect, overwriting the DOM of a component Chakra controls; Chakra's
`NumberInput` already syncs the input to the `value` it is handed. A
test pins that a value set from outside the field reaches the input.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(daisyui): position DateWidget's calendar before the browser paints it

The calendar popup measured the trigger and set its position from a
passive Effect, after paint, so it could show in its previous place for
a frame as it opened. Measuring and positioning is what layout Effects
are for; the resize and scroll listeners move with it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(daisyui): keep the frame provider's theme storage out of render

`DaisyUIFrameProvider` wrote the chosen theme to `localStorage` while
rendering and read the stored one on every render. It now reads it once
through a state initializer and writes a chosen theme from an Effect, so
rendering has no side effect and a render React discards writes nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(playground): show a broken shared link as an error banner instead of alerting from an Effect

The playground alerted from a mount Effect when the shared link's setup
could not be read, which StrictMode's second Effect run showed twice in
development. The error is read once as the module loads, so it renders
as a banner above the editors and is logged once, with no Effect.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor(core): drop ObjectField's seeded-property records from its handlers rather than a layout Effect

ObjectField kept its record of the seeds the add button wrote in step
with the data from a layout Effect on every `formData` change. The
handlers a write goes through now do it: the `onChange` the properties
report through, and the add, rename and remove handlers, each check the
record against the data the write left, read from the form. A write the
form refused, as `transformChange` can, or one a parent wrote the seed
back over keeps the record, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor(core): keep render output out of the store and submit after an edit without waiting for a commit

The model's store holds what operations make of the form and nothing a
render derives. Form's layout Effect only records the props and state
each commit rendered, which an operation starts from, deriving the
store's state under the committed props when an operation has run since
and sharing it with what is on screen, so a prop change takes one
commit again and no field renders for it twice. The render keeps its
last derivation in state, React's pattern for storing information from
previous renders, instead of a store update from an Effect.

`submit()` no longer queues: it submits before it returns. While the
inputs show the stored value it goes through `requestSubmit()`, so the
browser's constraint validation runs as for a submit button; after an
edit React has yet to render, it dispatches the submit event, and schema
validation alone checks the stored value.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(mantine): give a field's error id to one element from render, without a DOM check

`FieldErrorTemplate`'s hidden copy of a field's errors queried the
document after every commit and took the field's error id only while no
other element had it. Mantine's `FieldTemplate` now provides the id of
the field whose hidden copy it renders: under it, the copy has the
field's `errorId`, and the error element a Mantine widget, checkbox or
object/array template shows has none of the field's, so the inputs
described by the id read the errors once and a custom widget that shows
no errors is still described by them. Anywhere else, as for a oneOf
selector, a widget rendered by itself or a custom `FieldTemplate`, the
error element shown keeps the id and the copy has none.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(daisyui): report the date picker's blur from the handler that closes it

The picker reported blur, and the focus the trigger holds after it, from
a passive Effect of the close commit, and a pending blur from an unmount
cleanup, so the consumer heard of it after the parent rendered the save.
React asks a component to tell its parent from the event handler that
caused the change; the form stores an edit as `onChange` reports it, so
`getFormData()` in `onBlur` already reads the saved value. Done, a press
on the trigger, a press elsewhere and Escape now report the blur with the
value the close stores, and then any focus the trigger holds, from their
handlers; a press elsewhere that leaves the trigger focused still leaves
the trigger's own blur to report it. Both Effects are gone, and with them
`callWithDeferredThrow()` here: a throw from `onBlur` leaves the handler
as any event handler's does, and a `flushSync` from it runs at once
instead of being deferred with a React error. The trigger's blur reads
whether the popup is open from a ref the handlers set, since React has
not rendered the close yet when that blur arrives in the same event.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: describe the seed-only Form in one upgrade-guide section and per-change changelog entries

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(core): link the ignored-formData warning to the upgrade guide's recipes

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(mantine): pin which element has a field's error id for each FieldTemplate and widget pairing

A custom widget under a custom, non-Mantine FieldTemplate is described by
no element: the hidden copy leaves the id to an error element no widget
shows. That case is marked test.fails until the id is given to it from a
contract the copy can see.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: name the prop changes that re-derive defaults

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(core): describe the seed-only formData contract in comments

Comments and one test name still described a later formData prop being
taken as the form's data. Name the whole-form setFieldValue('', data) as
the unsanitized replacement instead, and drop the reasoning that relied
on a prop replacing the data.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(core): cover a oneOf/anyOf option switch refused by transformChange

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): validate only the data transformChange keeps

applyEdit applied the raw edit with applyChange, which live-validated it and
called customValidate and transformErrors on it, then applied a rewrite as a
second applyChange that validated again. A rewritten edit was validated twice
and a refused one once, on data the form never keeps.

applyChange is split into applyChangeToData (data, defaults, sanitization,
liveOmit, settled snapshot and pairing view) and applyChangeToErrorsOf (error
moves, own errors, live validation). applyEdit derives the edit's data, asks
transformChange, and validates once: the edit's data when taken, nothing when
refused (the state before the edit), and for a rewrite the edit's error moves
unvalidated followed by one validated root write.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): put a rewritten option switch's selector on the option its data fits

When `transformChange`, an `onChange` or a custom parent answered a
`oneOf`/`anyOf` switch with other data than the switch sent, the selector
stayed on the option the user picked and showed that option's empty fields.
The field read any change of data after a switch as the data following it.

The field now compares the data it gets back with the data its switch sent.
Data that came back as sent keeps the picked option; any other data keeps it
only while it still fits that option, and is re-matched otherwise, the way a
refused switch already was.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(core)!: deprecate formData in favour of initialFormData

`formData` is another name for the seed `initialFormData`, read only on
mount and on reset(), but its name reads as a controlled value. Tag it
`@deprecated` so editors and linters point v6 code at `initialFormData`.
It still works and still wins when both are passed.

The playground's samples seed through `initialFormData`; shared links
keep carrying their data as `formData`, which `loadedState` still reads. Tests seed through `initialFormData`
too, except those that pin the alias itself: the v6 echo pattern, a later
`formData` being ignored, `reset()` re-reading it and both props passed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): undo a refused move's bookkeeping and drop late blur/focus

- A reorder, insert, copy or rename that transformChange refuses puts the
  array's row keys and the object's property order back
- A transformChange rewrite keeps the fields' own errors, the root's included
- A deep-equal copy from transformChange counts as the edit itself
- A detached form drops blur and focus as it drops a change
- focusOnError escapes the id in its selector; a null formData is the seed;
  setFormElement releases the element on detach; stale comments fixed

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: link the changelog entries to #5556

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): warn once, in development, about a handle call a hidden or unmounted form drops

A `setFieldValue()`, `reset()` or `submit()` that reaches a form hidden by `<Activity>` or unmounted is dropped, as the contract says, but silently: a server response filling a hidden tab was lost with no trace. The call itself is a sign the caller has not noticed the form is detached, so the first one is warned about, once per form, with a link to the upgrade guide. A field's late change stays silent, since a widget flushing a draft from its Effect cleanup is expected then.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(core): address the first review round of the one-owner form

- A `transformChange` result deep-equal to the data before the edit refuses it, as that data itself does, so `sendMove()` reports the refusal and the array row keys and property order go back
- The props and state of a commit reach the model from an insertion Effect, which React runs before any layout Effect of the commit, so a command issued from a layout Effect anywhere in the tree starts from that commit's props
- The form attaches to its model from the first layout Effect in its subtree, so an edit a widget makes from a layout Effect as an `<Activity>` shows the form again, or as StrictMode replays the Effects, is taken
- A refused rename no longer moves the React key the last accepted rename gave another property
- `submit()` dispatches a submit event to an element another `tagName` renders, where it did nothing
- `pairingViewOfWrite()` walks the written data once, returning with each subtree's view whether it changed
- `extraErrorsAlone()` merges `extraErrors` the way #5553's `applySubmit()` did, so an array it holds for an array field's items is keyed by index
- The `transformChange` docs say it decides edits alone: what the form derives itself is reported without it

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(daisyui): fall back to the theme last stored when dataTheme is cleared

The frame provider read the stored theme once at mount, so clearing `dataTheme` after choosing one fell back to the theme stored at mount rather than the one the Effect had since written. The stored theme now follows the chosen one, adjusted while rendering as React documents for state that follows a prop.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* test(core): port the model tests #5553 added to the form

The one-owner form has no `formModel.test.ts`, so the three cases #5553 added there, a raised array holding nothing for an item, and a property named `__proto__` kept as a property in a raised array and across a sibling's rename, are pinned through the form's `onChange` instead. Its form-level tests seed through `initialFormData`.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* docs: restore the changelog entries of #5553 the rebase dropped

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(utils): fill a missing null value in whatever emptyObjectFields says

NullField used to write the null from an Effect under any
defaultFormStateBehavior. The defaults that replace it went through
maybeAddDefaultToObject(), which drops them under 'skipDefaults' and
for optional keys under 'populateRequiredDefaults', so a required
type: 'null' property stayed missing and failed the submit. A null
the fill made, and the objects that lead to it, are now added like a
const.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(chakra-ui): clear UpDownWidget's input when the form clears its value

Zag's NumberInput switches to its own state while value is undefined, so
without the Effect that wrote the input it kept showing the last number
after setFieldValue() or reset() cleared the value.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: give transformChange an example that holds per keystroke

Trimming on every keystroke removed a space as soon as it was typed,
and next.title.trim() threw once the title was cleared.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(core): say committed() runs from an insertion Effect, and why

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): defer a field change's consumer callbacks, and re-key rows a rewrite moved

A field's change now runs through callWithDeferredThrow() as a whole,
so a throw from transformChange, customValidate or transformErrors on a
change a widget reports from an Effect no longer unmounts the form, as
one from onChange already did not. A change that throws stores nothing,
so the move it carried counts as refused and ArrayField puts its rows
back.

sendMove() returns what became of the change: taken, refused, or
rewritten with the value the edit alone left at the path. ArrayField
keeps a row's key only where the form kept the item the handler put
there, and gives every other item a new row, so a transformChange that
sorts or filters never pairs one item's row instance with another.

applyEdit() shares a rewrite against the edit's data first, so a copy
that changes nothing of the edit takes it in one walk; a second walk
against the data before the edit runs only for a real rewrite or a
key move.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): keep a cleared field cleared through a transformChange rewrite

A rewrite is written over the whole form, and under
mergeDefaultsIntoFormData: 'useDefaultIfFormDataUndefined' its default
merge filled the cleared key back in, skipping the #5125 re-clear the
edit itself gets. The rewrite now carries the edit's cleared path, and
re-clears it when the rewrite leaves it without a value.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): keep a taken option switch whose derived defaults add to its data

MultiSchemaField told a taken switch from a refused or rewritten one by
whether the data came back deep-equal to what the switch sent, so
defaults the form derives for the switched value, such as a `then` it
turns on, made a taken switch look refused, and the selector could
move off the option the user picked. sendMove() now reports what the
form stored at the path for a taken change, and the field keeps its
choice while it renders that data; a refusal, a rewrite or a later
edit from onChange still re-matches the option.

MoveOutcome becomes a tagged union: refused, taken with the value
kept, or rewritten with the value kept and the value the edit alone
left; undefined when no form answered the change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(utils): report the null fill from computeDefaults' own recursion

holdsNullFill() walked each property's computed defaults again at every
object level, resolving $refs as it went, and saw only a property's own
properties and a top-level $ref. computeDefaults() now reports a null
fill through an onNullFill callback from the recursion it already does,
so a property brought in by $ref, allOf, if/then or dependencies counts,
and nothing is walked twice. Arrays don't report one: a field renders an
item only for one the data holds.

Where the allOf setting or emptyObjectFields leaves an object's allOf or
if out of its defaults, the field for a null property they bring in
still renders, so getObjectDefaults() adds just those nulls, computed
under settings that drop every other default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(mantine): leave the error id on the widget under a custom FieldErrorTemplate

FieldTemplate gave the field's error id to the hidden copy whenever it
rendered errors, so the error a Mantine widget shows dropped the id and
relied on FieldErrorTemplate to carry it. A custom FieldErrorTemplate
that doesn't call useErrorCopyId() left no element with the id the
input's aria-describedby names. The copy now takes the id only when
the field's FieldErrorTemplate, globally or per field, is this theme's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): warn when both seeds are passed, and not for an inline formData copy

Passing formData and initialFormData together seeds from formData with
nothing said; development now warns once, naming the seed that won.
warnIfFormDataIgnored() compared a new formData with the last one by
identity only, so an inline literal with unchanged content drew the
"ignored after mount" warning after the user had typed; it now falls
back to deepEquals().

The formData JSDoc and props page no longer promise that v6 code keeps
working: only the echo pattern does, and a formData that changes after
mount is ignored, silently in production.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): warn in development when a container field isn't handed the form's data

A custom field that wraps ArrayField or ObjectField has to pass
formData through unchanged, since their handlers read the form's value
at fieldPath. Breaking that failed silently: a wrapper that sorted the
list had remove act on another item. Both fields now compare, after the
commit, the formData they were rendered with against the form's data at
their path as that commit rendered it, and warn once on a difference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): hand a commit's props over before the cleanups of the fields it removes

React runs the layout cleanups of removed content while it walks the
tree in the mutation phase, and Form's own insertion Effect ran after
its subtree, so a widget that flushes a draft as a schema change
removes it reported through the previous commit's onChange and schema,
which FormRef's doc said can't happen. The handoff is now a Handoff
component rendered first inside the form element, whose insertion
Effect React runs before it reaches any field below. FormRef's doc and
the internals page name the one exception left: a sibling of the form
that the commit removes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(playground): keep its form data in step with the form, and remount only the form

The form fills in the defaults of a new schema, uiSchema or default
state setting without calling onChange, so the formData editor, the
share link and the raw validation went on showing the data from before
until a field was edited. An Effect now re-reads getFormData() after
the commit that passes such a change, as it would sync with any
external store. The stale "controlled parent" comment goes.

An edit in the formData editor bumped the key every seeded form shared,
remounting the theme, subtheme and validator selectors and the options
drawer's settings form, two of which were siblings under the same key.
A load now bumps loadKey, which keys those, and an edit bumps a key of
the main form's alone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): order a rename transformChange rewrites by the data it kept

A rewritten rename was recorded as taken: the property order and the React key moved to the name the field sent,
which the kept data may not hold, so a key-normalizing transformChange moved the property to the end, and one that
put the old name back gave two properties the same React key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): drop a submit event that reaches a form hidden by Activity

handleSubmit had no detached check, so a native submit (a <button form> outside the Activity, requestSubmit()) of a
hidden form called onSubmit for valid data, and a form first rendered hidden was never detached at all.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): keep the submit event submit() dispatches from an enclosing form

For a tagName other than form, submit() dispatched a bubbling SubmitEvent, so an enclosing <form>'s onSubmit (the
reason tagName exists) ran as well.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): drop the rows an array change sent once a commit renders without them

ArrayField installed the rows a handler reads only when the rendered rows changed, so after a change that never
reached the form (a custom field refusing a remove) the next handler started from the rows that change sent and
handed one item's row instance to another.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(mantine): read a ui:globalOptions FieldErrorTemplate when deciding who takes the error id

FieldTemplate resolved the FieldErrorTemplate from the field's own ui:options only, so a custom one set through
ui:globalOptions, which SchemaField renders, was taken for Mantine's: no element had the error id and the widget's
aria-describedby pointed at nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(daisyui): report the undefined a date picker's close stores as undefined

reportBlur and reportFocus defaulted their value parameter to the rendered value, so a Done on an empty field, which
stores ui:emptyValue's undefined, reported the old '' to onBlur and onFocus.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(utils): fill in the null of an option that is null only through a type list

getDefaultFormState() left out the null of any rendered anyOf/oneOf option getSchemaType() reads as null, but
MultiSchemaField renders no field only for a literal type: 'null', so an option of type: ['null'] rendered NullField
with no value: a required property could no longer be submitted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor(utils): add the skipped branches' nulls without a type assertion

The null fill added an `objectDefaults as GenericObjectType` assertion; an isObject() narrowing in the same condition
does the same job.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor(core): escape focusOnError's selector with CSS.escape()

The hand-rolled asCssString() re-implemented the platform's CSS.escape(), which the Mantine theme used for the same
job before this branch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): keep a property in its place when transformChange refuses its removal

handleRemoveProperty dropped the key from the property order before sending the removal, so a removal the form
refused left the property rendered after all the others.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): warn when a parent puts its seed record back as formData

The ignored-formData warning skipped every object the form had held, the seed included, since a render that adds no
defaults hands the seed object back. A v6 Cancel button that sets the parent's state back to the original record was
therefore ignored without a warning. Only the data operations make, which onChange reports, is held now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: stop describing a formData passed after mount as replacing the data

internals.md, validation.md, form-props.md and typescript.md still said a new formData prop reaches the form or is
validated, and the getDefaultFormState() reference did not say it can return null or fills null values.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): throw an error from onSubmit, onError or validation out of submit()

submit() submits inside the event it fires, where the browser reports a
throw instead of handing it to the caller, so an error onSubmit, onError,
customValidate or transformErrors threw never came out of submit(), as the
upgrade guide says one does from every FormRef call. The submit submit()
runs now keeps the throw and submit() throws it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): let transformChange refuse a key move that leaves the data as it was

A move such as swapping two equal items leaves data equal to the data
before it, which the store shares back as that very object, so
transformChange got one object as both next and previous and returning
previous took the move: each row's state, an option chosen for it, went to
the other item. transformChange now gets a copy of that data as next.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): defer a throw from a blur's validation as a change's is

Under liveValidate: 'onBlur', a blur ran customValidate and transformErrors
unwrapped: only its onChange went through callWithDeferredThrow(). A widget
that reports a blur from an Effect, inside React's commit, then unmounted the
form on a throw that the same callback deferred for a change. The whole blur
now runs the way a field's change does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): keep the ignored-formData warning quiet for JSON copies and scalar roots

The development warning about a formData passed after mount fired for a
parent that stores a JSON copy of each edit once a field was cleared, since
the copy leaves out the key the form holds as undefined, and for a scalar
root's undo or late store, since only objects were remembered as held. It
now compares with undefined as missing, remembers scalars by value, and
stops comparing once it has warned. Production no longer keeps the seed
alive for it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): warn when transformChange returns undefined for an edit that left data

A transformChange written with a block body that returns only on the path
that refuses, (next, previous) => { if (...) return previous; }, returns
undefined for every other edit, which empties the form, defaults included,
and hands onChange an undefined formData its type does not allow. The form
now warns about it once in development, and the docs say so, and that what
transformChange returns is filled in with the schema's defaults.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): rekey an array's rows wherever the form keeps other items than a change sent

ArrayField kept the rows a change sent unless transformChange refused or
rewrote it, so a remove the defaults answered by putting an item back
(minItems with mergeExtraDefaults), or a reorder that onChange set back with
setFieldValue(), left rows paired with other items than they showed, and
each row's state, an option chosen or focus, went with them. The handler
now reads what the form holds after the change and keeps a row only where
that is the item the change put there, for a rewrite as before and for
these. The kept items are read through the field's reader rather than from
the outcome's unknown value, which Array.isArray() let through as any[].

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): keep a new property's seed record outside a Form until it is renamed

Outside a Form, ObjectField's handlers read the data of the last commit,
so the add button, checking its seed record against the data right after
sending it, found no new property there and dropped the record: renaming
the property then kept its 'New Value' under a name a numeric pattern
describes. The handlers now read what they sent until the next commit, as
ArrayField's do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): take a key move only with the value it was announced for

The form took a field's announced key move for whatever change reached its
path. A custom parent field that put other data in place of the change, as
one keeping an option switch from happening by writing the old value back,
had the switch reported as taken, so the selector stayed on the option the
data did not fit and rendered its required input over the old data. A move
now carries the value it describes, and a change bringing another value at
the path moves nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): warn once per field about a container not passed the form's data

The development warning about a custom field handing ArrayField or
ObjectField other formData than the form holds kept its once-only flag per
instance, so a field remounted with a key warned again each time, and named
the field by its id alone, which two fields can share across idSeparator.
It now goes through logOnce() with fieldLabelForLog(), as the other field
warnings do, and production builds skip the check rather than scheduling an
Effect in every container on every change. isDevelopment moves to a module
of its own so the hook can read it as it loads: it is imported inside the
cycle formState.ts starts by building the registry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): pair a row a container write changes with the row the view moved there

A container write with no move announced, as setFieldValue() makes, paired
every changed position with the data at that index before the last moves.
After a reorder that is another row, so a row the write changed in place was
compared with its neighbour's previous value, the next sanitize missed the
conditional the change flipped, and kept values the new branch rejects. The
write also filled a position whose pairing a move of another length had
dropped. A changed item now pairs with the view's item, the one a reorder
put there; only an item set back to the data as it last settled pairs with
that (#5451); a dropped position stays unpaired. pairingViewOfWrite(), a
one-line wrapper, goes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor(core): merge the errors a reset or valid submit leaves through mergeErrors()

extraErrorsAlone() spelled the merge of extraErrors into nothing with its own
validationDataMerge() call, where every derivation goes through mergeErrors(),
so the errors shown right after a reset or a submit could drift from what the
next derivation of the same state shows if mergeErrors() changed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): live-validate an edited form on a prop change though it had no seed

Whether a prop change re-validates the data was decided once, at mount, from
whether the props passed any, so a form with no seed under liveValidate:
'onChange' never re-validated after the user edited it: a schema change
dropped the errors the user had earned and nothing brought them back, where
v6 re-validated whatever data was there. An edit now counts as data to
validate, and a reset decides again from the seed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(utils): fill a null schema's value in wherever the field rendered for it holds one

The null getDefaultFormState() fills in for a null schema, in place of the
one NullField used to write as it mounted, missed values its field holds:
one the data holds as undefined, which the merge keeps over a default; a
property that is null only through its own allOf or if/then/else, or an own
property the object's allOf makes null, under allOf: 'skipDefaults'; an
item of an array, or an additional property, the data holds, whose null did
not reach the objects above under skipDefaults or populateRequiredDefaults;
and a default: null. Each is filled in now. It is no longer filled in for an
optional object the Optional Data Controls render without their fields, nor
for an anyOf/oneOf option that is null once its allOf is merged, whose field
renders nothing. The allOf branches are only searched for a null in a schema
that names the null type somewhere.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): keep the null of a null field a write clears or a condition retypes

A setFieldValue() that clears a null field was kept cleared like any other
field's, and a condition retyping a property to null left it cleared too:
the sanitize loop ended on a repeated round with the data sanitize left,
which the fill had not seen, so the null it would have written was missing
and the required error had no field to fix it. A null field now has nothing
to clear, and a repeating round ends on filled data.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(playground): read the form's data back after every remount, not only a schema edit

The playground re-read the form's data after a schema, uiSchema or settings
change, but not after the remounts it makes itself, a load, an edit in the
formData editor or a theme switch, so the defaults the remounted form filled
in were missing from the editor, the share link and the raw validation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: say what a hidden form drops through Suspense, a null ref and a wrapper that hands on part of its data

The upgrade guide now says that React clears the ref of a hidden form, so the
dropped-call warning only reaches a handle kept from before, that the ref is
back only after the fields' layout Effects of the commit that shows the form
again, and that a Suspense fallback hides a form the way Activity does, which
the warning now names too. A custom field that hands ArrayField or
ObjectField part of its data under its own fieldPath loses data, not just
order. The getDefaultFormState() reference, a FallbackField comment that
still had NullField writing a null, and the DaisyUI date picker's claim
about the value a close reports are brought up to date.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: describe where getDefaultFormState() fills a null in, in the changelog

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* chore(size): raise the @rjsf/core, Form and @rjsf/utils own budgets by 1 kB

The review fixes take @rjsf/core to 33.32 kB, the Form canary to 33.09 kB and
@rjsf/utils' own code to 27.12 kB brotlied, each over its budget.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(playground): read the form's data back after every mount, also one a frame delays

The read-back Effect ran on the commit that remounted the form, but the
themes rendered inside the demo frame (MUI, antd, DaisyUI, Mantine) mount the
form only once the frame is ready, a commit later, so the Effect found no form
and the defaults it filled in never reached the formData editor, the share
link or the raw validation. The form is now held in state through a callback
ref, so each mount, whatever caused it, hands over a new FormRef and the
Effect reads that form's data.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(core): say what formData is without comparing it with v6, and who sets an array field back

The comparison with v6 belongs to the upgrade guide. With formData only a seed,
onChange cannot set a field back; setFieldValue() can.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): keep a property named __proto__ as a key when moving keys to diff errors

withKeysMoved() built the moved object by assignment, so a JSON-sourced
__proto__ key set the prototype instead and dropped out of the comparison.
A rename that leaves the data without that key then counted it as unchanged,
and its validator error stayed on a property the data no longer holds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): sanitize a transformChange rewrite as the edit it stands for

The rewrite is written over the whole form as a root change, and root
writes are taken as written, so a rewrite that switched a conditional kept
the values of the branch it left, which the same switch made in the field
drops. A root write now carries the path of the edit it stands for, and is
sanitized as that edit would be; setFieldValue('', data) is still taken as
written.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(utils): fill in no null inside an optional object the optional data controls show collapsed

The null of a type 'null' schema was dropped for such an object only from the
rule that adds it whatever emptyObjectFields says, but the object's default
still held it, so under populateAllDefaults and skipEmptyDefaults that
non-empty default was stored anyway: the object rendered expanded and
validation reported its required fields on an object the user never added.
The collapsed object is now known before its defaults are computed, and no
null is filled in below it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor(chakra-ui,daisyui,mantine): leave the theme Effects to #5563 and #5548

The Chakra and DaisyUI Effect removals don't depend on who owns the form's
data, so they move to their own PR, #5563, which is cut from v7.

Mantine's FieldErrorTemplate goes back to v7's. Deciding the error id in
render compared the template in use with the theme's own, and still left a
custom widget under a custom FieldTemplate undescribed. #5548, in the #5490
stack, decides which element draws a field's errors from the field's
presentation plan, which a widget declares, and replaces the same layout
Effect.

The theme packages now differ from v7 only in tests moved to
initialFormData.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): leave the selector where it was when transformChange refuses a switch

A refused option switch set the selector to the option picked and then
kept it there whenever the data still fitted that option, which data does
whenever no option requires a property. A switch the form refused looked
taken. The rule came from the parent-owned form, where a parent declining
a switch and one taking it with the same data couldn't be told apart.
Here the form knows: sendOptionSwitch() returns the refusal, so the
selection isn't changed at all, as a refused edit leaves an input alone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(utils): fill the null of a property named __proto__ in as an own key

The null fill of a branch the settings skip wrote `fills[key] = ...` and
merged the fills with Object.assign(). For a JSON-sourced `__proto__`
property, both go through the prototype setter, so the fill re-pointed the
fills object's prototype and the null was lost. Both now write through
setOwn(), as #5524 does for every other default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): key array rows by the items the form made of a change

`commitRows()` compared the items the form holds after an add, copy,
remove or reorder with the rows the handler sent, and for a change
`transformChange` rewrote with what the change alone left. Two cases
went wrong:

- A remove that `transformChange` rewrote, where the defaults put an
  item back (`minItems` with `arrayMinItems.populate`), matched the
  change's own data, which already held the put-back item, so the rows
  were left at the length the handler sent. The render then fell back
  on the keys from before the remove, and the removed item's row showed
  the next item.
- A change the form took as sent was compared with the raw rows, so an
  item the form only derived, such as one whose extra data a live omit
  dropped, got a new row and remounted, losing its focus and state.

Both now compare with what the form made of the change, `kept` for a
change taken and `edited` for one rewritten, and keep the rows only
when the form holds as many items as the change sent.

Regression tests: "when the defaults put an item back after a remove
that transformChange rewrites" and "should keep the row of an item the
form only derived, as a live omit does, across an add" both failed
before this change and pass after it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor(core): fill the defaults of a data pass through one helper

The sanitize round that repeats filled the defaults with a copy of the
fill at the top of the loop, which added a second `as T` cast. Both now
go through `fillDefaults()`, which takes the result through an overload
trust point instead of a cast.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(core): say which of what the form derives transformChange skips is reported

The `transformChange` JSDoc said the defaults for a new schema are reported
through `onChange`; they are only stored, and only a blur's live omit and
`reset()` are reported.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): announce an option switch with the value its container stores

A key move is taken only by the change carrying the value it was announced
with, but `ArrayField` stores a cleared item as `null` and `ObjectField` a
cleared `additionalProperties` entry as `''`, so an option switch that
clears such a value announced `undefined` and the form received the
container's value instead. The move was never taken: the option's errors
stayed, no outcome came back, and the selector re-matched the stored
`null` or `''` and could go back to the option the user left.

The two coercions are now one rule, `storedValue()`, which both containers
apply and which the option switch applies to the value it announces and
sends, so the change reaching the form is the one the move describes.

Three `transformChange` tests set a row's option up by a switch their rule
refused; that switch clears the item, and only the unmatched move let the
selector follow it. They now refuse only the edit they are about.

The two new tests in oneOf.test.tsx failed before the fix and pass after.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): decide a removed property's place from what became of the removal

`handleRemoveProperty` kept the key in the property order whenever the
data read back after `onChange` still held it. That read reflects the
removal only when `onChange` has already stored it: outside a `Form` it
returns what the field last sent, and under a parent field that stores
the change later the form still holds the key. The order then kept the
name, and the next Add, which picks that free name again, rendered the
new property at the removed one's old place instead of last.

The removal is now announced like a rename, as a change that moves no
key, and the order follows its outcome: a removal `transformChange`
refused, or a rewrite that kept the property, leaves it in place, and
anything else, including a removal no form answered as it was sent,
takes it out. `AnnouncedMove.newKeyOf` is optional for such a change.

The new ObjectField test, with a parent field that passes changes on a
microtask later, failed before the fix and passes after.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): hand a commit's props over before a replaced root field's cleanups

React runs the cleanups of an element's removed children before it walks
the children that stay, so a direct child of the form element the commit
removed ran its layout cleanups before `Handoff`'s insertion Effect. A
root field replaced by a new `fields.SchemaField`, an error list or
`children` flushed a draft under the previous commit's props, with the old
`transformChange` and `onChange`.

Everything the form renders after `Handoff` and `Attachment` now sits in a
fragment, whose removed children React cleans up when its walk reaches the
fragment, after `Handoff`. A fragment adds no element, so no theme's
markup or snapshot changes, and the `FormRef` and internals docs'
"before the cleanup of any field the commit removes" now holds for the
root field too.

The new Form.ownership test, which switches `fields.SchemaField`, failed
before the fix (the flush reported through the first commit's `onChange`)
and passes after.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): resolve the schema again for the data a repeating sanitize round ends on

When the sanitize loop ends on a repeated hash, it stores the fill of
what sanitize left, but kept the `retrievedSchema` it resolved at the top
of that iteration, for the data before the fill. Every other exit commits
a schema resolved for the data it stores. The schema is now resolved
again after that fill.

No input in the suite reaches a mismatch: the two that reach this exit
(NullField's condition that retypes a property to `null`, and a variant
with a second `if` reading that `null`) repeat the previous round's
sanitized data, whose fill is the data the iteration resolved its schema
for. The exit is also taken on a hash equal to an earlier pass's data
before sanitizing, where that does not hold, so the resolve keeps the
exit consistent by construction. It runs only on this exit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(utils): read the ui:definitions entry when deciding an optional object is collapsed

The check that keeps the `null` fill out of an optional object the
Optional Data Controls render collapsed read the property's own uiSchema
entry alone. `computeDefaults()` and the field merge in the
`ui:definitions` entry of a definition the property `$ref`s, so an
object whose definition's entry turns the controls on was taken as
expanded: its `null` fie…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sanitizeDataForNewSchema() drops the empty minItems placeholders of a scalar enum array, so any change in a form with a conditional empties the list

2 participants