Skip to content

Commit 2a0a034

Browse files
committed
fix(studio): classify stale delete previews
1 parent 2278c11 commit 2a0a034

3 files changed

Lines changed: 4 additions & 2 deletions

File tree

packages/studio/src/hooks/domEditCommitRunner.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export type DomEditCommitDeclineReason =
7272
| "geometry-property"
7373
| "styles-not-editable"
7474
| "not-text-editable"
75+
| "preview-stale"
7576
| "persist-failed";
7677

7778
export type DomEditCommitOutcome = { ok: true } | { ok: false; reason: DomEditCommitDeclineReason };

packages/studio/src/hooks/useElementLifecycleOps.multiDelete.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,6 @@ describe("useElementLifecycleOps — deleting a canvas multi-selection", () => {
145145
});
146146

147147
expect(showToast.mock.calls.flat().join(" ")).toContain("out of date");
148-
expect(outcome).toEqual({ ok: false, reason: "persist-failed" });
148+
expect(outcome).toEqual({ ok: false, reason: "preview-stale" });
149149
});
150150
});

packages/studio/src/hooks/useElementLifecycleOps.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ export function useElementLifecycleOps({
175175
// matching at all means the preview is describing a document the file
176176
// does not have — say so rather than reporting a delete that happened.
177177
reloadPreview();
178-
throw new Error("Nothing to delete — the preview was out of date. Try again.");
178+
showToast("Nothing to delete, the preview was out of date. Try again.");
179+
return domEditCommitDeclined("preview-stale");
179180
}
180181
const patchedContent =
181182
typeof removeData.content === "string" ? removeData.content : originalContent;

0 commit comments

Comments
 (0)