Skip to content

Commit

Permalink
fix(List): add identifier, use label.text as key
Browse files Browse the repository at this point in the history
  • Loading branch information
chohner committed Mar 4, 2024
1 parent 880d054 commit 9b6e0b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/components/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ type ListProps = z.infer<typeof ListPropsSchema>;

const List = ({ identifier, items, heading, isNumeric }: ListProps) => {
return (
<div className="ds-stack-8 scroll-my-40">
<div className="ds-stack-8 scroll-my-40" id={identifier}>
{heading && <Heading {...heading} />}
<ol className="list-none ds-stack-32 ps-0">
{items.map((item, index) => (
<li
key={item.identifier ?? item.headline?.text ?? item.content}
key={
item.identifier ??
item.label?.text ??
item.headline?.text ??
item.content
}
className="first:pt-0 scroll-my-40"
>
<ListItem {...item} numeric={isNumeric ? index + 1 : undefined} />
Expand Down
1 change: 1 addition & 0 deletions tests/unit/components/__snapshots__/storybook.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ exports[`Storyshots Page/List Example 1`] = `
>
<div
className="ds-stack-8 scroll-my-40"
id="default-list-id"
>
<h2
className="ds-heading-02-reg"
Expand Down

0 comments on commit 9b6e0b7

Please sign in to comment.