fix: Checking for children to decide if we should render paragraph vs div

Approved-by: Matilda Landström
This commit is contained in:
Erik Tiekstra
2025-11-28 11:49:02 +00:00
parent 3a6abb73c2
commit e621570f99

View File

@@ -307,11 +307,18 @@ export const renderOptions: RenderOptions = {
return next(node.children, embeds, fullRenderOptions)
}
// Determine whether to use a div or p based on children.
// Some children use div or sections as wrappers and these are
// not allowed inside p tags.
const Elem = node.children.some((child) => 'children' in child)
? 'div'
: 'p'
return (
<Typography key={node.uid} variant="Body/Paragraph/mdRegular">
<p className={cx(styles.p, className)} {...props}>
<Elem className={cx(styles.p, className)} {...props}>
{next(node.children, embeds, fullRenderOptions)}
</p>
</Elem>
</Typography>
)
},