Repository navigation
Description
Describe the Bug
When a publish fails validation, the form correctly enters the submitted state and shows error indicators (red fields, ErrorPill on collapsed blocks/arrays, tab badges). The very next edit triggers autosave, which submits a draft with skipValidation: true. That request succeeds, and the success branch of Form.submit unconditionally calls setSubmitted(false), which removes every error indicator while the document is still invalid.
The net effect for editors on a collection with drafts.autosave (and no drafts.validate): validation highlights are visible for exactly autosave.interval milliseconds after the first keystroke, then vanish. On large pages with nested blocks it is very hard to find what actually blocks publishing.
Relevant code (v3.90.2):
packages/ui/src/forms/Form/index.tsx, success branch ofsubmit:if (res.status < 400) { // ... setSubmitted(false) setProcessing(false)
packages/ui/src/elements/Autosave/index.tsxcalls that samesubmitwithoverrides: { _status: 'draft' }, skipValidation: !validateOnDraft.
A submit that skipped validation cannot know the form is valid, so it should not clear the submitted/error state. Suggested fix: keep submitted untouched when the submit ran with skipValidation (or let Autosave pass an explicit flag), e.g.
if (!skipValidation) {
setSubmitted(false)
}The existing guard in Autosave (skipSubmission = submitted && !valid && validateOnDraft) only protects the drafts.validate: true case; without validate: true there is no protection.
Link to the code that reproduces this issue
Reproducible with the repository's own test suite: test/versions, collection autosave-posts (test/versions/collections/Autosave.ts: autosave.interval: 100, required title and description).
Reproduction Steps
pnpm dev versions, log in, open Autosave Posts, create a document, filltitleanddescription, publish.- Clear
description(required). Wait for autosave (draft saves fine, drafts are not validated). - Click Publish changes. Validation fails,
descriptionis highlighted and the toast "Please correct invalid fields" appears. Expected so far. - Type one character into
title. - After ~100 ms autosave runs, succeeds, and the highlight on
descriptiondisappears. The document is still not publishable, but nothing in the UI indicates why or where.
Same behaviour with server-side errors (e.g. a select value no longer in options inside a collapsed block): the block shows 1 Error after publish, then loses it on the next autosave.
Expected: error indicators from a failed publish stay until the fields are actually valid (i.e. until a validated submit succeeds), regardless of intermediate draft autosaves.
Which area(s) are affected?
area: ui
Environment Info
payload: 3.90.2
next: 16.3.6
@payloadcms/db-mongodb: 3.90.2
@payloadcms/ui: 3.90.2
react: 19.2.3
node: 22 / 26 (reproduced on both)
pnpm: 10.22.0
Platform: darwin arm64
Activity