Skip to content

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

Description

@digitalwerber

Version

@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

  1. Set up an array with a select unit and a number field whose admin.condition is (_, siblingData) => siblingData.unit === 'km'.
  2. Type into another field of the row. After 250 ms a refresh request is sent.
  3. 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.
  4. 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

  1. self-assigned this
    on Nov 22, 2026
  2. added a commit that references this issue on Nov 23, 2026
    7c766ec
  3. github-actions commented on Nov 24, 2026

    @github-actions
    Contributor

    🚀 This is included in version v4.0.0-beta.12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions