Skip to content

Conversation

@evanyan13
Copy link
Contributor

@evanyan13 evanyan13 commented Sep 24, 2025

The Issue:

  • When variation_slicing is in place, there will be multiple items in the response with the same item_id.
  • This causes React to have trouble differentiating components, leading to unexpected rendering behavior.

Key Changes

  • Update key assignment to SectionItem to use item?.data?.variation_id as the primary key as item.id as the fallback
  • This ensures uniqueness of key, whether variation_slicing is in place or not
  • Removed key as an explicit prop in SectionItemProps and SectionItemsListProps
    • The key field is a special prop that is used by React internally and it is not being passed down to the component as part of the props object. Such, there is no need to define it in the component props explicitly.

@evanyan13 evanyan13 marked this pull request as draft September 24, 2025 16:53
@evanyan13 evanyan13 marked this pull request as ready for review September 25, 2025 03:51
@evanyan13 evanyan13 requested review from a team and stanlp1 September 25, 2025 03:52
@evanyan13 evanyan13 self-assigned this Sep 25, 2025
export interface SectionItemProps {
item: Item;
children?: ReactNode;
key?: string;
Copy link
Contributor Author

@evanyan13 evanyan13 Sep 25, 2025

Choose a reason for hiding this comment

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

  • Suggesting to remove key as an explicit prop in SectionItemProps and SectionItemsListProps as

  • The key field is a special prop that is used by React internally and it is not being passed down to the component as part of the props object. Such, there is no need to define it in the component props explicitly.

@esezen esezen requested a review from Copilot September 25, 2025 19:02
Copy link

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 fixes a React rendering issue where duplicate item_id values caused by variation slicing led to components rendering more items than expected. The fix ensures unique React keys by prioritizing variation_id over item.id.

  • Updated key assignment logic to use item?.data?.variation_id as primary key with item?.id as fallback
  • Removed unnecessary key prop definitions from TypeScript interfaces since React handles keys internally

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/components/Autocomplete/SectionItemsList/SectionItemsList.tsx Updated key assignment for SectionItem components and removed key from props interface
src/components/Autocomplete/SectionItem/SectionItem.tsx Removed key prop from SectionItemProps interface

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@evanyan13 evanyan13 merged commit 070b97c into main Sep 25, 2025
8 of 10 checks passed
@evanyan13 evanyan13 deleted the noci-bugfix-duplicate-item-rendering branch September 25, 2025 20:51
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.

3 participants