fix(search): key search results by urn so a re-sort does not crash the page
Problem
The search results list (app/searchV2/SearchResultList.tsx) renders an antd List without a rowKey. In that case antd keys each row by its position (list-item-${index}).
After a re-sort or a new query, the same React component instance at a given position renders whichever entity now lands there, instead of a fresh card being mounted for the new entity. Any per-card state, and any hooks that depend on the entity, carry over from the previous entity.
In OSS this is latent today. It becomes a crash as soon as a card's hooks depend on the entity type: for example, a card menu that calls a delete-mutation hook only for some entity types changes its hook count when the entity at that position changes type, and React throws "Rendered more hooks than during the previous render", which replaces the results with the error boundary. DataHub Cloud hit exactly this with its configurable search card after switching the sort a few times.
Fix
- Pass
rowKey={(item) => item.entity.urn}to theListinSearchResultList. Each entity gets its own card, so one card instance never renders two different entities. Search results are unique by urn. - A card is now remounted when a different entity takes its position, instead of being re-rendered with new props.
The same change is in DataHub Cloud, so this keeps OSS and DataHub Cloud aligned.
Verification
-
yarn type-checkpasses. -
eslintandprettier --checkpass on the changed file. -
The PR conforms to DataHub's Contributing Guideline (PR Title Format)
š¤ Generated with Claude Code
Summary by cubic
Fixes a crash on the unstable search page that happened after re-sorting results. The antd List in SearchResultList now keys each row by the entity URN instead of its list position, so when a re-sort moves a different entity into a given position, its card is remounted rather than reused with new props. This prevents React from throwing "Rendered more hooks than during the previous render" when card hooks depend on the entity type.