perf(ui): skip rendering custom field components hidden by admin.condition#16780
Draft
jacobsfletch wants to merge 9 commits into
Draft
perf(ui): skip rendering custom field components hidden by admin.condition#16780jacobsfletch wants to merge 9 commits into
jacobsfletch wants to merge 9 commits into
Conversation
… admin.condition Initial form-state build was eagerly rendering every field's custom components (Field, BeforeInput, AfterInput, Description, Error, Label, RowLabel), including server components, even when the field's admin.condition resolved false. The rendered React element was baked into fieldState.customComponents and only hidden client-side by WatchCondition — work was already done. Gate the renderFieldFn call in addFieldStatePromise on `passesCondition !== false`. When the condition later flips true via onChange, lastRenderedPath is undefined so renderField produces a fresh element with a current timestamp. Note: inline function conditions only. Path-valued string refs (`./Path#export`) are not resolved server-side in iterateFields yet — those still pre-render.
Contributor
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖 |
…s collection Keeps base Posts collection from accruing condition-specific fixtures.
Cleaner than matching against a magic title string.
…n.condition Previously only the render call was gated on passesCondition; the switch still ran filterOptions resolves (DB queries on relationship/upload), blocks validation, and full recursion into hidden subtrees. Add an early-exit guard so a failing condition writes a minimal state entry and returns, skipping access checks, validation, switch processing, filterOptions, and child iteration. The client re-requests form state on condition flips, so the minimal entry is sufficient.
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.
Form state was eagerly rendering custom components even when the field's
admin.conditionevaluates to false. The rendered React component was only being hidden client-side, but should have deferred rendering entirely.This has potentially serious performance implications for two reasons:
Now, custom server components DO NOT render unless they pass conditions, as expected. Custom components will now only render if they will be mounted to the page.
Before:
Screen.Recording.2026-05-29.at.10.21.27.AM.mp4
After:
Screen.Recording.2026-05-29.at.10.19.26.AM.mp4