Hi, I am creating a tab component as shown in this documentation (I’m using Svelte) - Adding Children to Custom Components - Builder.io, But I am not able to view add Block section in the visual editor and when I drag and drop any component/block on my tabFields component for a particular tab it gets added throughout all the tabs and on deleting it from a particular tab it gets deleted from all of them, attaching the screenshots and code below for reference.
Screenshots-
now when i drag and drop a particular component on Blog tab it is also getting added to Contact tab and vice versa
This is the response I am getting on consoling the builderBlock props
@type: "@builder.io/sdk:Element"
@version: 2
children: [{…}]
component:
name: "TabFields"
options:
tabList: Array(2)
0: {children: Array(0), tabName: 'Blogs'}
1: {children: Array(0), tabName: 'Contact'}
length: 2
Here is my code for TabComponent.svelte:
<script lang="ts">
import * as BuilderSDK from '@builder.io/sdk-svelte';
export let tabList: any[];
export let builderBlock:any;
export let builderContext:any [];
let activeTab:any = 0;
function selectTab(tab:any) {
activeTab = tab;
}
$:{console.log("Active Tab", tabList[activeTab], builderBlock, builderContext);}
</script>
<div class="lg:mx-[130px] section-header overflow-hidden">
<h2 class="mx-4 mb-5 text-3xl bold">Stay up to date</h2>
<div class="tabs-wrap">
<button class="hidden">prev</button>
<div class="tabs flex">
{#if tabList}
{#each tabList as tab, index}
<button
class="py-6 px-4 border-b-4 border-solid cursor-pointer font-bold text-xl leading-normal whitespace-nowrap text-[#333] {activeTab === index ? 'border-green-500' : 'border-[#fff]'}"
on:click={() => selectTab(index)}
>
{tab.tabName}
</button>
{/each}
{/if}
</div>
<button class="hidden">next</button>
</div>
{#if tabList && tabList?.length != 0}
<slot/>
<BuilderSDK.Blocks
parent={builderBlock?.id}
path={`component?.options?.tabList?.${activeTab}.children`}
blocks={tabList[activeTab]?.children}
/>
{/if}
</div>
This is how i am registering the component in builder.io
{
component: TabSection,
name: 'TabFields',
canHaveChildren: true,
inputs: [
{
name: 'tabList',
type: 'list',
subFields: [
{
name: 'tabName',
type: 'string',
},
{
name: 'children',
type: 'blocks',
defaultValue: []
}
]
}
]
}