Conversation
korgon
commented
Jan 8, 2026
- adding 'index' to cloneWithProps so that index position can be known inside of result component
There was a problem hiding this comment.
Pull request overview
This PR adds index position information to the RecommendationBundle component by passing an index prop to cloned result components. This enables result components to be aware of their position within the bundle.
Key Changes:
- Introduced index offset calculation to account for seed positioning
- Added
indexprop tocloneWithPropscalls for both regular results and seed results
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| const renderedResults = useMemo(() => { | ||
| // when seed is not in carousel and we have a seed, offset the index by 1 | ||
| const indexOffset = hasSeed && resultsToRender.filter((result) => result.bundleSeed == true).length ? 0 : 1; |
There was a problem hiding this comment.
Use strict equality (===) instead of loose equality (==) when comparing bundleSeed to true. This prevents potential type coercion issues.
| const indexOffset = hasSeed && resultsToRender.filter((result) => result.bundleSeed == true).length ? 0 : 1; | |
| const indexOffset = hasSeed && resultsToRender.filter((result) => result.bundleSeed === true).length ? 0 : 1; |
|
|
||
| const renderedResults = useMemo(() => { | ||
| // when seed is not in carousel and we have a seed, offset the index by 1 | ||
| const indexOffset = hasSeed && resultsToRender.filter((result) => result.bundleSeed == true).length ? 0 : 1; |
There was a problem hiding this comment.
The indexOffset logic is inverted. When a seed exists but is not in the carousel (filter returns 0), the offset should be 1 (to account for the seed at position 0), but the current ternary returns 0. When the seed is in the carousel, no offset is needed, but the code returns 1. The condition should be: hasSeed && resultsToRender.filter((result) => result.bundleSeed === true).length === 0 ? 1 : 0;
| const indexOffset = hasSeed && resultsToRender.filter((result) => result.bundleSeed == true).length ? 0 : 1; | |
| const indexOffset = | |
| hasSeed && resultsToRender.filter((result) => result.bundleSeed === true).length === 0 ? 1 : 0; |