Merge layout compatibility fix into dnd kit

This commit is contained in:
Thomas Camlong committed 2026-08-09 18:03:37 +02:00
commit 03ecfef429
2 files changed
+15 -3

No files matched your search

+10 -2
View File
@@ -44,8 +44,16 @@ describe("section behavior validation", () => {
});
});
it.each(["category", "dynamic"])("rejects the legacy %s kind", (kind) => {
expect(() => sectionSchema.parse({ id: "legacy", kind, layouts: [] })).toThrow();
it("normalizes the legacy dynamic kind to a container", () => {
expect(sectionSchema.parse({ id: "legacy", kind: "dynamic", layouts: [] })).toMatchObject({
id: "legacy",
kind: "container",
layouts: [],
});
});
it("rejects the legacy category kind", () => {
expect(() => sectionSchema.parse({ id: "legacy", kind: "category", layouts: [] })).toThrow();
});
it.each([
+5 -1
View File
@@ -93,4 +93,8 @@ const containerSectionSchema = z.object({
),
});
export const sectionSchema = z.union([emptySectionSchema, containerSectionSchema]);
const legacyDynamicSectionSchema = containerSectionSchema
.extend({ kind: z.literal("dynamic") })
.transform((section) => ({ ...section, kind: "container" as const }));
export const sectionSchema = z.union([emptySectionSchema, containerSectionSchema, legacyDynamicSectionSchema]);