From 429bbae77ce767463997765e17801dca8942f328 Mon Sep 17 00:00:00 2001 From: Shubham Padia Date: Mon, 28 Jul 2025 13:47:28 +0000 Subject: [PATCH] help-beta: Flatten only in case of matching tagName. In the commits following this, we are going to make changes which will introduce cases with paragraphs, code blocks and other elements inside list items. Right now, FlattenList will just break in those cases. We need to return those elements without flattening since those are valid elements inside a list item. --- help-beta/src/components/FlattenList.astro | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/help-beta/src/components/FlattenList.astro b/help-beta/src/components/FlattenList.astro index 586e91cc3e..5e7619995b 100644 --- a/help-beta/src/components/FlattenList.astro +++ b/help-beta/src/components/FlattenList.astro @@ -26,12 +26,15 @@ const flattened = { if (other.type === "comment") { return []; } - assert.ok( - other.type === "element" && - (other.tagName === first_element.tagName || - other.tagName === "aside"), - ); - return other.children; + assert.ok(other.type === "element"); + // Flatten only in case of matching tagName, for the rest, we + // return the elements without flattening since asides, code + // blocks and other elements can be part of a single list item + // and we do not want to flatten them. + if (other.tagName === first_element.tagName) { + return other.children; + } + return [other]; }), }; ---