Skip to content

Commit

Permalink
fix: insert properly from marketplace (#4725)
Browse files Browse the repository at this point in the history
Fixes #4723

We removed body from template data but didn't fix roots. Later insertion
logic started to rely on these roots.
  • Loading branch information
TrySound authored Jan 6, 2025
1 parent 91e6b23 commit 387530b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions apps/builder/app/builder/features/marketplace/templates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,16 @@ const insertSection = ({
instanceId: string;
}) => {
const fragment = extractWebstudioFragment(data, instanceId);
fragment.instances = fragment.instances.filter(
(instance) => instance.component !== "Body"
const body = fragment.instances.find(
(instance) => instance.component === "Body"
);
// remove body and use its children as root insrances
if (body) {
fragment.instances = fragment.instances.filter(
(instance) => instance.component !== "Body"
);
fragment.children = body.children;
}
const insertable = findClosestInsertable(fragment);
if (insertable) {
insertWebstudioFragmentAt(fragment, insertable);
Expand Down

0 comments on commit 387530b

Please sign in to comment.