Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

fix: Allow inserting templates only inside container components (#2491)

Giuseppe4fb015931268
diff --git a/apps/builder/app/builder/features/ai/apply-operations.ts b/apps/builder/app/builder/features/ai/apply-operations.ts
index 354901487a..da07bc4d84 100644
--- a/apps/builder/app/builder/features/ai/apply-operations.ts
+++ b/apps/builder/app/builder/features/ai/apply-operations.ts
@@ -77,6 +77,15 @@ const insertTemplateByOp = (
const instanceSelector = computeSelectorForInstanceId(operation.addTo);
if (instanceSelector) {
+ const currentInstance = instancesStore.get().get(instanceSelector[0]);
+ // Only container components are allowed to have child elements.
+ if (
+ currentInstance &&
+ metas.get(currentInstance.component)?.type !== "container"
+ ) {
+ return;
+ }
+
const dropTarget: DroppableTarget = {
parentSelector: instanceSelector,
position: operation.addAtIndex + 1,