Repository navigation
test(ui): cover autosave behavior with virtual fields - #18144
Conversation
…the save response With drafts + autosave enabled, a single user edit could produce two PATCH requests. The first response re-populates `virtual: true` fields via their `afterRead` hooks, `acceptValues` merges those values into form state, and autosave's `dequal` comparison — which only excluded `updatedAt` — saw the change as a new user edit and submitted again. Consumers such as audit logging then recorded two entries for one change. Autosave now excludes virtual fields (and anything nested beneath one) from that comparison, alongside `updatedAt`. Form state carries a new `isVirtual` flag so the exclusion covers nesting, blocks, and tabs without re-deriving paths on the client. Also fixes the form-dirty tracking that let the second request through: `setModified(false)` after a submit runs while the autosave is still flagged as background processing, so the interceptor recorded it as "modified while processing" and skipped the next reset — leaving the form permanently dirty after every other autosave. Only becoming modified is tracked now.
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖
Largest pathsThese visualization shows top 20 largest paths in the bundle.Meta file: packages/next/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js
Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js
DetailsNext to the size is how much the size has increased or decreased compared with the base branch of this PR.
|
jacobsfletch
left a comment
There was a problem hiding this comment.
Couple things before merging:
- We're already reducing fields to values, so I'd like to avoid the extra passes over form state in
reduceFieldsToComparableValues. - Virtual fields can still be editable when
admin.readOnly: false. Filtering them out prevents those edits from triggering autosave.
Pretty sure we could just drop the filtering and add the modified check to the existing guard. I'll push that shortly.
|
No actionable comments were generated in the recent review. ℹ️ Recent review info
Walkthrough
Merge Risk:
|
|
🚀 This is included in version v4.0.0-beta.6 |
Adds regression coverage for autosave responses that update virtual fields, including editable virtual inputs. The submission tracker resets from #18631 already prevent duplicate saves on
main.3.x back-port here: #19096