I have created a custom component ‘Menu’ and added a subfield of type block. I need a feature where the rest of the UI will be displayed from my react component and one of the fields is editable from builder.
Followed everything that is given in How to Add Dynamic Editing Regions to Custom Components and tried the given solutions. Also tried to copy the same code just to check if it works.
However, everytime I try to add any block, it gets added after the whole section block and not inside my HTML code where I’ve included the builder component.
Here is my custom component code:
Builder.registerComponent(MenuComponent, {
name: "Menu",
inputs: [
{
name: "menuItems",
type: "list",
helperText: "Main Navigation Menu Items",
subFields: [
{
name: 'blocks',
type: 'blocks',
hideFromUI: true,
helperText: 'This is an editable region where you can drag and drop blocks.',
defaultValue: [
{
'@type': '@builder.io/sdk:Element',
component: {
name: 'Text',
options: {
text: 'Enter some text...',
},
},
},
],
},
{
name: "navigationTitle",
type: "string",
required: true,
helperText: "Main Navigation Title",
},
{
name: "navigationLink",
type: "url",
helperText: "Main Navigation Title URL",
}
],
},
],
});
Here is the Menu react component in which I’ve included the builder block:
<div>
{menuItems.map((menuItem, index) => {
return (
<a
key={index}
href={menuItem.navigationLink}
id={menuItem.navigationTitle}
>
{menuItem.navigationTitle}
<BuilderBlocks
key={index}
child
parentElementId={menuItems.builderBlock && menuItems.builderBlock.id}
blocks={menuItem.blocks}
dataPath={`component.options.menuItems.${index}.blocks`}
/>
</a>
);
})}
</div>
The block that is getting added is not inside my div and a tag. Could you please help me with this?