You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Form: a form-state answer arriving within the 250 ms debounce after a change marks that change as sent, so conditions and new array rows are not refreshed #19842
@payloadcms/ui 4.0.0-beta.11. The same logic is on main after #19649.
Describe the bug
A field change sometimes never reaches the server form state. Fields with admin.condition that depend on the change stay hidden, and an array row added with "Add row" keeps its loading shimmer. Both last until the user edits something else.
Cause
Form (forms/Form/index.tsx) queues a refresh 250 ms after the last change, but only when formState differs from prevFormStateRef.
When a refresh answer arrives, MERGE_SERVER_STATE (forms/Form/fieldReducer.ts) sets prevStateRef.current to the merged state. That state includes local changes made while the request was pending.
If the answer arrives within 250 ms after such a change, the debounced effect later compares the merged state with itself. It finds no difference, so no refresh is sent for the change.
To reproduce
Set up an array with a select unit and a number field whose admin.condition is (_, siblingData) => siblingData.unit === 'km'.
Type into another field of the row. After 250 ms a refresh request is sent.
While that request is pending, choose km, so that its answer arrives less than 250 ms later. To make this deterministic, delay the form-state server action response, e.g. with Playwright's page.route.
The conditional field never appears. The same happens with "Add row" in step 3: the new row stays in its loading state.
Expected behavior
A change made while a refresh is pending is still sent in a following refresh.
Possible fix
In refreshFormState (forms/Form/useFormState.ts), keep a reference to contextRef.current.fields when the request is built. On a refresh answer, pass prevStateRef only if contextRef.current.fields is still that reference. Otherwise leave prevFormStateRef unchanged, so the debounced effect sees the difference and queues one more refresh. Save, validate, reset and autosave stay as they are. We run this as a local patch.
Activity
fix(ui): prevent stale responses from overwriting form state (payload…
github-actions commentedon Nov 24, 2026
🚀 This is included in version v4.0.0-beta.12