Skip to content

Commit

Permalink
fix(core): issue with keys in form components (#1197)
Browse files Browse the repository at this point in the history
* fix(core): issue with keys in input components

* fix: set key before spreading props

* chore: update changeset
  • Loading branch information
jorgemoya authored Aug 1, 2024
1 parent 51704d9 commit c831677
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/lovely-falcons-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bigcommerce/catalyst-core": patch
---

Set key before spreading prop in some form components.
6 changes: 5 additions & 1 deletion core/components/ui/pick-list/pick-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ const PickList = forwardRef<ElementRef<typeof RadioGroupPrimitive.Root>, Props>(
const { defaultImage, label, value, onMouseEnter, ...itemProps } = item;

return (
<div className="flex items-center p-4" key={value} onMouseEnter={onMouseEnter}>
<div
className="flex items-center p-4"
key={`${id}-${value}`}
onMouseEnter={onMouseEnter}
>
{Boolean(defaultImage) && (
<BcImage
alt={defaultImage?.altText || ''}
Expand Down
2 changes: 1 addition & 1 deletion core/components/ui/rectangle-list/rectangle-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ const RectangleList = forwardRef<ElementRef<typeof RadioGroupPrimitive.Root>, Pr

return (
<RadioGroupPrimitive.Item
key={`${id}-${value}`}
{...itemProps}
className="border-2 px-6 py-2.5 font-semibold text-black hover:border-primary focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-primary/20 disabled:border-gray-100 disabled:text-gray-400 disabled:hover:border-gray-100 data-[state=checked]:border-primary"
key={`${id}-${value}`}
value={value}
>
{item.label}
Expand Down
2 changes: 1 addition & 1 deletion core/components/ui/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ const Select = forwardRef<ElementRef<typeof SelectPrimitive.Trigger>, Props>(

return (
<SelectPrimitive.Item
key={`${id}-${value}`}
{...optionProps}
className={
'relative flex w-full cursor-pointer select-none items-center justify-between overflow-visible px-4 py-2 outline-none hover:bg-secondary/10 hover:text-primary focus-visible:bg-secondary/10 data-[disabled]:pointer-events-none data-[state="checked"]:bg-secondary/10 data-[state="checked"]:text-primary data-[disabled]:opacity-50'
}
key={`${id}-${value}`}
value={value}
>
<SelectPrimitive.ItemText>{label}</SelectPrimitive.ItemText>
Expand Down
2 changes: 1 addition & 1 deletion core/components/ui/swatch/swatch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ const Swatch = forwardRef<ElementRef<typeof RadioGroupPrimitive.Root>, Props>(

return (
<RadioGroupPrimitive.Item
key={`${id}-${value}`}
{...itemProps}
className="group h-12 w-12 border-2 bg-white p-1 hover:border-primary focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-primary/20 disabled:border-gray-100 disabled:hover:border-gray-100 data-[state=checked]:border-primary"
key={`${id}-${value}`}
title={label}
value={value}
>
Expand Down

0 comments on commit c831677

Please sign in to comment.