Skip to content

Comments

Index in RecommendationBundle#1424

Open
korgon wants to merge 1 commit intodevelopfrom
clone-with-index
Open

Index in RecommendationBundle#1424
korgon wants to merge 1 commit intodevelopfrom
clone-with-index

Conversation

@korgon
Copy link
Contributor

@korgon korgon commented Jan 8, 2026

  • adding 'index' to cloneWithProps so that index position can be known inside of result component

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 index prop to cloneWithProps calls 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;
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use strict equality (===) instead of loose equality (==) when comparing bundleSeed to true. This prevents potential type coercion issues.

Suggested change
const indexOffset = hasSeed && resultsToRender.filter((result) => result.bundleSeed == true).length ? 0 : 1;
const indexOffset = hasSeed && resultsToRender.filter((result) => result.bundleSeed === true).length ? 0 : 1;

Copilot uses AI. Check for mistakes.

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;
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Suggested change
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;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant