Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: Add key property to list children in Highlight component #26471

Merged
merged 1 commit into from Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions code/ui/manager/src/components/sidebar/SearchResults.tsx
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