Repository navigation
perf(ui): reduce number of field renders on submit - #13524
Merged
Merged
Conversation
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.
|
JarrodMFlesch
approved these changes
Aug 20, 2025
jacobsfletch
added a commit
that referenced
this pull request
Aug 20, 2025
) 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: ```ts { type: 'array', hooks: { beforeChange: [ ({ value }) => !value?.length ? [ // this is an added/computed row if attempt to save with no rows ] : value, ], }, // ... } ``` 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: 1. When merging server form state, we receive the new fields, but do not receive the new rows. This is because the `acceptValues` flag only applies to the `value` property of fields, but should also apply to the `rows` property on `array` and `blocks` fields too. 2. When creating new form state on the server, the newly added rows are not being flagged with `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 set `renderAllFields` to false in order receive this property as expected. Fixed by #13524. Before: https://github.com/user-attachments/assets/3ab07ef5-3afd-456f-a9a8-737909b75016 After: https://github.com/user-attachments/assets/27ad1d83-9313-45a9-b44a-db1e64452a99 --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1211094073049042
Contributor
|
🚀 This is included in version v3.53.0 |
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.
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.