frame bg: drop legacy color if flag missing

This commit is contained in:
Ryan Di
2026-03-18 19:53:24 +11:00
parent 858d1d4cce
commit 48bc930c09
2 changed files with 10 additions and 2 deletions
+9 -1
View File
@@ -509,9 +509,17 @@ export const restoreElement = (
name: element.name ?? null,
});
case "frame":
const hasBackgroundEnabled = Object.prototype.hasOwnProperty.call(
element,
"backgroundEnabled",
);
const backgroundEnabled = (element as any).backgroundEnabled ?? false;
return restoreElementWithProperties(element, {
name: element.name ?? null,
backgroundEnabled: (element as any).backgroundEnabled ?? false,
backgroundEnabled,
...(hasBackgroundEnabled
? {}
: { backgroundColor: DEFAULT_ELEMENT_PROPS.backgroundColor }),
});
// Don't use default case so as to catch a missing an element type case.
@@ -95,7 +95,7 @@ describe("restoreElements", () => {
null,
)[0] as ExcalidrawFrameElement;
expect(restoredFrame.backgroundColor).toBe("#ffc9c9");
expect(restoredFrame.backgroundColor).toBe("transparent");
expect(restoredFrame.backgroundEnabled).toBe(false);
});