Merged in fix/SW-1831-accordion-error-key-prop-is-missing (pull request #1496)

fix(SW-1831): add fragment

* fix(SW-1831): add fragment

* fix(SW-1831): move fragment to nodesToHtml

* fix(SW-1831): remove import

* fix(SW-1831): add getUniqueId


Approved-by: Erik Tiekstra
Approved-by: Matilda Landström
This commit is contained in:
Fredrik Thorsson
2025-03-10 08:03:07 +00:00
parent b6ee3664f0
commit 44c9a15ea9
3 changed files with 16 additions and 7 deletions

View File

@@ -29,12 +29,7 @@ export default async function ParkingAmenity({
<ParkingInformation key={data.type} parking={data} />
))}
{parkingPageUrl && (
<Button
className={styles.parkingPageLink}
theme="base"
intent="secondary"
asChild
>
<Button theme="base" intent="secondary" asChild>
<Link
href={`/${parkingPageUrl}`}
color="burgundy"

View File

@@ -15,6 +15,7 @@ export default function JsonToHtml({
if (!Array.isArray(nodes) || !nodes.length) {
return null
}
return (
<section className={cx(styles.container, className)}>
{nodesToHtml(nodes, embeds, renderOptions).filter(Boolean)}

View File

@@ -1,3 +1,5 @@
import React from "react"
import { renderOptions } from "./renderOptions"
import styles from "./jsontohtml.module.css"
@@ -130,6 +132,13 @@ export function nodeToHtml(
}
}
function getUniqueId(node: RTENode) {
if ("uid" in node) {
return node.uid
}
return node.id
}
export function nodesToHtml(
nodes: RTENode[],
embedsArray: Node<Embeds>[],
@@ -137,7 +146,11 @@ export function nodesToHtml(
) {
const embeds = groupEmbedsByUid(embedsArray)
const fullRenderOptions = { ...renderOptions, ...overrideRenderOptions }
return nodes.map((node) => nodeToHtml(node, embeds, fullRenderOptions))
return nodes.map((node, index) => (
<React.Fragment key={getUniqueId(node) ?? `node-${index}`}>
{nodeToHtml(node, embeds, fullRenderOptions)}
</React.Fragment>
))
}
export function makeCssModuleCompatibleClassName(