Skip to content

AI-native design editor. Open-source Figma alternative.

Sections are top-level only: can't nest inside frames or groups

Danila Poyarkovb83dfcdbe45b
diff --git a/src/composables/use-canvas-input.ts b/src/composables/use-canvas-input.ts
index 1585a4406..fcc09b592 100644
--- a/src/composables/use-canvas-input.ts
+++ b/src/composables/use-canvas-input.ts
@@ -535,7 +535,12 @@ export function useCanvasInput(
}
// Check if we're hovering over an auto-layout frame
- const dropTarget = store.graph.hitTestFrame(cx, cy, store.state.selectedIds, store.state.currentPageId)
+ let dropTarget = store.graph.hitTestFrame(cx, cy, store.state.selectedIds, store.state.currentPageId)
+ // Sections can't be dropped into frames or groups
+ const movingSection = [...store.state.selectedIds].some(id => store.graph.getNode(id)?.type === 'SECTION')
+ if (movingSection && dropTarget && dropTarget.type !== 'SECTION' && dropTarget.type !== 'CANVAS') {
+ dropTarget = null
+ }
const dropParent = dropTarget ? store.graph.getNode(dropTarget.id) : null
if (dropParent && dropParent.layoutMode !== 'NONE') {
diff --git a/src/stores/editor.ts b/src/stores/editor.ts
index 546f058c3..0ba078f58 100644
--- a/src/stores/editor.ts
+++ b/src/stores/editor.ts
@@ -269,7 +269,11 @@ export function createEditorStore() {
}
function reparentNodes(nodeIds: string[], newParentId: string) {
+ const parent = graph.getNode(newParentId)
for (const id of nodeIds) {
+ const node = graph.getNode(id)
+ // Sections can only live in pages (CANVAS) or other sections
+ if (node?.type === 'SECTION' && parent && parent.type !== 'CANVAS' && parent.type !== 'SECTION') continue
graph.reparentNode(id, newParentId)
}
requestRender()