Skip to content

Commit

Permalink
Merge pull request #26471 from storybookjs/valentin/fix-missing-key-f…
Browse files Browse the repository at this point in the history
…ield

UI: Add key property to list children in Highlight component
(cherry picked from commit be079d3)
  • Loading branch information
valentinpalkovic authored and storybook-bot committed Mar 19, 2024
1 parent e90524d commit 49c14ee
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions code/ui/manager/src/components/sidebar/SearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ const Highlight: FC<PropsWithChildren<{ match?: Match }>> = React.memo(function
const { value, indices } = match;
const { nodes: result } = indices.reduce<{ cursor: number; nodes: ReactNode[] }>(
({ cursor, nodes }, [start, end], index, { length }) => {
nodes.push(<span>{value.slice(cursor, start)}</span>);
nodes.push(<Mark>{value.slice(start, end + 1)}</Mark>);
nodes.push(<span key={`${index}-1`}>{value.slice(cursor, start)}</span>);
nodes.push(<Mark key={`${index}-2`}>{value.slice(start, end + 1)}</Mark>);
if (index === length - 1) {
nodes.push(<span>{value.slice(end + 1)}</span>);
nodes.push(<span key={`${index}-3`}>{value.slice(end + 1)}</span>);
}
return { cursor: end + 1, nodes };
},
Expand Down

0 comments on commit 49c14ee

Please sign in to comment.