Preserve row state when search results reorder
Replace the index-based React key with the result’s stable ID so expanded and selected states stay attached to the correct row.
Recalled from Slack
Why this fix was made
Matched
Search results are re-ranked when streaming completes. Index keys can move expanded state to the wrong row; use the result ID so React preserves the right item.
Slack · #frontend
Frontend team · Today, 3:42 PM
Exact code citation
Opens and highlights line 42 in the diff.
src/components/SearchResults.tsx
+1 −1
39
return (
40
<ul className="results">
41
{results.map((result, index) => (
42
−
<ResultRow key={index} result={result} />
42
+
<ResultRow key={result.id} result={result} />
43
))}
44
</ul>
45
);