Skip to content

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

Drag outside frame reparents to parent, clip content toggle

Danila Poyarkov66e68f734992
diff --git a/src/components/properties/LayoutSection.vue b/src/components/properties/LayoutSection.vue
index c11ce2a25..3d02af283 100644
--- a/src/components/properties/LayoutSection.vue
+++ b/src/components/properties/LayoutSection.vue
@@ -248,4 +248,17 @@ function setAlignment(primary: LayoutAlign, counter: LayoutCounterAlign) {
</div>
</template>
</div>
+
+ <!-- Clip content (for all frames) -->
+ <div v-if="node.type === 'FRAME'" class="border-b border-border px-3 py-2">
+ <label class="flex cursor-pointer items-center gap-2 text-xs text-surface">
+ <input
+ type="checkbox"
+ class="accent-accent"
+ :checked="node.clipsContent"
+ @change="store.updateNodeWithUndo(node.id, { clipsContent: !node.clipsContent }, 'Toggle clip content')"
+ />
+ Clip content
+ </label>
+ </div>
</template>
diff --git a/src/composables/use-canvas-input.ts b/src/composables/use-canvas-input.ts
index 9b182377c..2979689c6 100644
--- a/src/composables/use-canvas-input.ts
+++ b/src/composables/use-canvas-input.ts
@@ -739,6 +739,20 @@ export function useCanvasInput(canvasRef: Ref<HTMLCanvasElement | null>, store:
const dropId = store.state.dropTargetId
if (dropId) {
store.reparentNodes([...store.state.selectedIds], dropId)
+ } else {
+ // Reparent to grandparent if dragged outside parent bounds
+ for (const id of store.state.selectedIds) {
+ const node = store.graph.getNode(id)
+ if (!node?.parentId || node.parentId === store.graph.rootId) continue
+ const parent = store.graph.getNode(node.parentId)
+ if (!parent || parent.type !== 'FRAME') continue
+ const outsideX = node.x + node.width < 0 || node.x > parent.width
+ const outsideY = node.y + node.height < 0 || node.y > parent.height
+ if (outsideX || outsideY) {
+ const grandparentId = parent.parentId ?? store.graph.rootId
+ store.graph.reparentNode(id, grandparentId)
+ }
+ }
}
}
store.setDropTarget(null)
diff --git a/src/engine/renderer.ts b/src/engine/renderer.ts
index 4d2ece6b7..0789d13ee 100644
--- a/src/engine/renderer.ts
+++ b/src/engine/renderer.ts
@@ -588,7 +588,7 @@ export class SkiaRenderer {
}
// Clip + render children for containers
- if (node.type === 'FRAME' && node.childIds.length > 0) {
+ if (node.type === 'FRAME' && node.clipsContent && node.childIds.length > 0) {
canvas.save()
canvas.clipRect(
this.ck.LTRBRect(0, 0, node.width, node.height),
diff --git a/src/engine/scene-graph.ts b/src/engine/scene-graph.ts
index 38f8fcc40..6431cddba 100644
--- a/src/engine/scene-graph.ts
+++ b/src/engine/scene-graph.ts
@@ -102,6 +102,7 @@ export interface SceneNode {
visible: boolean
locked: boolean
+ clipsContent: boolean
text: string
fontSize: number
@@ -162,6 +163,7 @@ function createDefaultNode(type: NodeType, overrides: Partial<SceneNode> = {}):
cornerSmoothing: 0,
visible: true,
locked: false,
+ clipsContent: true,
text: '',
fontSize: 14,
fontFamily: 'Inter',