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
fix(ui): save button becomes disabled after failed save with draft validation (#14584)
### What?
Fixed an issue where the Save Draft button becomes disabled after a
failed save operation when draft validation is enabled, preventing users
from retrying without making additional form changes.
### Why?
When `versions.drafts.validate` is enabled, if a draft save fails (due
to validation errors, network issues, or server errors), the Save Draft
button would become disabled. This is problematic because:
1. Users cannot retry the save without making arbitrary changes to the
form
2. The behavior is inconsistent with unvalidated drafts, which always
allow saving
3. Transient failures (network errors, temporary third-party service
issues) become permanent blocks
The root cause: `setModified(false)` is called early in the submit flow
for ALL saves (line 365), which marks the form as "unmodified". When a
draft save subsequently fails, the form remains marked as unmodified,
which triggers the disabled state for the Save Draft button on update
operations (since `disabled = operation === 'update' && !modified`).
### How
- Added targeted logic in the error handler that explicitly restores the
modified state for failed draft saves
- When `overridesFromArgs['_status'] === 'draft'` and the save fails,
call `setModified(true)` to mark the form as modified again
- This ensures the Save Draft button remains enabled for retry on update
operations
- Also added `validateDrafts` to the submit callback's dependency array
to prevent stale closure issues
Fixes#14227
'Check this box to simulate a validation failure. The save button should remain enabled after the failure.',
27
+
},
28
+
defaultValue: false,
29
+
},
30
+
{
31
+
name: 'validatedField',
32
+
type: 'text',
33
+
admin: {
34
+
description:
35
+
'This field will fail validation if "Fail Validation" checkbox is checked. This simulates validation failures from business logic, network errors, or third-party validation.',
36
+
},
37
+
validate: (value,{ data })=>{
38
+
// Simulate a validation failure based on the checkbox state
39
+
if(data?.failValidation){
40
+
return'Validation failed: This is a simulated validation error to test save button behavior.'
* This interface was referenced by `Config`'s JSON-Schema
184
+
* via the `definition` "draft-validation".
185
+
*/
186
+
exportinterfaceDraftValidation{
187
+
id: string;
188
+
title: string;
189
+
/**
190
+
* Check this box to simulate a validation failure. The save button should remain enabled after the failure.
191
+
*/
192
+
failValidation?: boolean|null;
193
+
/**
194
+
* This field will fail validation if "Fail Validation" checkbox is checked. This simulates validation failures from business logic, network errors, or third-party validation.
195
+
*/
196
+
validatedField?: string|null;
197
+
description?: string|null;
198
+
updatedAt: string;
199
+
createdAt: string;
200
+
_status?: ('draft'|'published')|null;
201
+
}
202
+
/**
203
+
* This interface was referenced by `Config`'s JSON-Schema
204
+
* via the `definition` "payload-kv".
205
+
*/
206
+
exportinterfacePayloadKv{
207
+
id: string;
208
+
key: string;
209
+
data:
210
+
|{
211
+
[k: string]: unknown;
212
+
}
213
+
|unknown[]
214
+
|string
215
+
|number
216
+
|boolean
217
+
|null;
218
+
}
178
219
/**
179
220
* This interface was referenced by `Config`'s JSON-Schema
0 commit comments