block-content-to-hyperscript icon indicating copy to clipboard operation
block-content-to-hyperscript copied to clipboard

Duplicate List Items

Open rothnic opened this issue 5 years ago • 2 comments

If you have a simple block with a bulleted list, where the list has a single list item in it, I get a duplicate list item.

<ul>
    <li></li>
</ul>
<li></li>

Instead of:

<ul>
    <li></li>
</ul>

rothnic avatar Mar 12 '20 21:03 rothnic

I'm using this with svelte-portable-text.

It turns out that if I manually set renderContainerOnSingleChild in block-content-to-hyperscript/lib/blocksToNodes.js, then it fixes my issue.

svelte-portable-text doesn't seem to pass the option along if I set it. However, I'm not sure if the core issue of rendering the element twice is a problem of this library or the svelte library.

rothnic avatar Mar 13 '20 14:03 rothnic

Another update. I'm using the svelte/sapper blog starter with sanity. I am able to configure renderContainerOnSingleChild by adding it as a property here in svelte-portable-text.

I then have a line in the blog starter like this:

<BlockContent blocks={myObject.body} {serializers} renderContainerOnSingleChild={true} />

With this statement, I no longer have the duplicates. Swapping renderContainerOnSingleChild={true} for renderContainerOnSingleChild={false} will bring the issue back.

So, my question would be, should this setting be required to not run into this duplicate text list item issue?

rothnic avatar Mar 13 '20 20:03 rothnic