Skip to content

Commit

Permalink
Avoid map key conflict for document results (#456)
Browse files Browse the repository at this point in the history
* Avoid map key conflict for document results

We currently can't have VerticalResults for document verticals since
two results from the same entity will cause a map key conflict.
To resolve this, we are making the key the result ID and the result
index which should always be unique.

J=WAT-4282
TEST=manual,auto

Created a test document search config on the test-site which previously
failed to return VerticalResults properly due to the key error
now returns the results and updates on a new search

* Update snapshots

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
sahilvaidya and github-actions[bot] authored Aug 12, 2024
1 parent d21223b commit 01ecfa9
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 1 deletion.
Binary file modified .storybook/snapshots/__snapshots__/mapboxmap--custom-pin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .storybook/snapshots/__snapshots__/mapboxmap--primary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/components/VerticalResultsDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ function renderResult<T>(
CardComponent: CardComponent<T>,
result: Result<T>
): JSX.Element {
return <CardComponent result={result} key={result.id || result.index}/>;
const key = result.id && result.index ? `${result.id}-${result.index}` : result.id || result.index;
return <CardComponent result={result} key={key}/>;
}

0 comments on commit 01ecfa9

Please sign in to comment.