sitesmith: narrow CANVAS_TYPES to just Container

The canonical Craft.js state from real saves shows that layout shells
(Section, BackgroundSection, HeroSimple, FeaturesGrid, ColumnLayout,
CTASection, FormContainer, Navbar, Footer) all serialize with
isCanvas:false. Only Container instances are canvases. The shells use
internal <Element canvas id="..."> linkedNodes for their drop targets.

Our previous CANVAS_TYPES set claimed all those shells were canvases,
which made Craft.js's toNodeTree walker hit an uncaught Invariant —
the shell asserted "I'm a canvas" but its render ignores data.nodes,
so the walker would chase phantom children.
This commit is contained in:
2026-05-24 16:27:38 -07:00
parent 6428f93cec
commit 849f432330
2 changed files with 13 additions and 16 deletions

View File

@@ -3,12 +3,12 @@ import type { NodeTree } from '@craftjs/core';
import { usePages } from '../state/PageContext';
import { SitesmithResponse, SerializedTreeNode } from '../types/sitesmith';
/** Component types that act as drop targets (isCanvas = true) */
const CANVAS_TYPES = new Set([
'Container', 'Section', 'ColumnLayout', 'BackgroundSection',
'HeroSimple', 'FeaturesGrid', 'CTASection',
'FormContainer', 'Navbar', 'Footer',
]);
/** Only Container is a "real" Craft.js canvas in serialized state. Layout
* shells (Section/HeroSimple/ColumnLayout/etc) use <Element canvas> linkedNodes
* internally — their own node must serialize with isCanvas:false or
* toNodeTree's walker hits an Invariant because the shell claims to be a
* canvas but its render ignores `data.nodes`. */
const CANVAS_TYPES = new Set(['Container']);
/**
* Flatten a SerializedTreeNode tree into a Craft.js node map ready for