Fix self-inflicted edit conflicts: dialogs no longer pin a stale node version
Properties, Raw JSON and AI proposals sent the version captured when the dialog opened. Any other edit to the node meanwhile (style chip, drag handle, inline text, child insert/move) bumped it, so the save 409'd against the user's own work. Save through ctrl.saveData instead: compare only the keys being written against the current node (a real conflict is a key someone else changed) and send no version. 409 toasts now show the server's reason. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3fdf415847
commit
d3fb060016
5 files changed
+55
-8
No files matched your search
@@ -27,7 +27,7 @@ function Properties({ node, schema, ctrl, close }: EditorProps) {
|
||||
const changed = Object.keys(patch).length > 0
|
||||
const save = async () => {
|
||||
setSaving(true)
|
||||
const res = await ctrl.setData(node.id, patch, { version: node.version })
|
||||
const res = await ctrl.saveData(node.id, node.data ?? {}, patch)
|
||||
setSaving(false)
|
||||
if (res) close()
|
||||
}
|
||||
@@ -70,7 +70,7 @@ function RawJson({ node, ctrl, close }: EditorProps) {
|
||||
<JsonArea value={node.data ?? {}} onChange={setDraft} />
|
||||
{Object.keys(patch).length > 0 && (
|
||||
<footer className="cms-actions">
|
||||
<button className="cms-btn cms-btn--primary" onClick={async () => (await ctrl.setData(node.id, patch, { version: node.version })) && close()}>
|
||||
<button className="cms-btn cms-btn--primary" onClick={async () => (await ctrl.saveData(node.id, node.data ?? {}, patch)) && close()}>
|
||||
<Icon name="save" size={16} /> Save
|
||||
</button>
|
||||
</footer>
|
||||
|
||||
Reference in new issue
Block a user