Repository navigation
fix: accept computed array and block rows from server form state - #13501
Merged
Merged
Conversation
jacobsfletch
requested review from
AlessioGr,
JarrodMFlesch and
denolfe
as code owners
August 18, 2025 14:28
Contributor
📦 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.
|
This reverts commit 3dbf1f4.
JarrodMFlesch
previously approved these changes
Aug 20, 2025
jacobsfletch
added a commit
that referenced
this pull request
Aug 20, 2025
Needed for #13501. No need to re-render all fields during save, and especially autosave. Fields are already rendered. We only need to render new fields that may have been created by hooks, etc. We can achieve this by sending previous form state and new data through the request with `renderAllFields: false`. That way form state can be built up from previous form state, while still accepting new data. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1211094406108904
JarrodMFlesch
approved these changes
Aug 20, 2025
Contributor
|
🚀 This is included in version v3.53.0 |
jacobsfletch
added a commit
that referenced
this pull request
Aug 22, 2025
Continuation of #13501. When merging server form state with `acceptValues: true`, like on submit (not autosave), rows are not deeply merged causing custom row components, like row labels, to disappear. This is because we never attach components to the form state response unless it has re-rendered server-side, so unless we merge these rows with the current state, we lose them. Instead of allowing `acceptValues` to override all local changes to rows, we need to flag any newly added rows with `addedByServer` so they can bypass the merge strategy. Existing rows would continue to be merged as expected, and new rows are simply appended to the end. Discovered here: https://discord.com/channels/967097582721572934/967097582721572937/1408367321797365840 --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1211115023863814
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If you have a beforeChange hook that manipulates arrays or blocks by adding rows, the result of that hook will not be reflected in the UI after save or autosave as you might expect.
For example, this hook that ensures at least one array row is populated:
When you save without any rows, this hook will have automatically computed a row for you and saved it to the database. Form state will not reflect this fact, however, until you refresh or navigate back.
This is for two reasons:
acceptValuesflag only applies to thevalueproperty of fields, but should also apply to therowsproperty onarrayandblocksfields too.addedByServer, and so never make it into form state when it is merged in on the client. To do this we need to send the previous form state to the server and setrenderAllFieldsto false in order receive this property as expected. Fixed by perf(ui): reduce number of field renders on submit #13524.Before:
before.mp4
After:
after.mp4