Skip to content

Commit

Permalink
fix: using index avoid uniqueid (#312)
Browse files Browse the repository at this point in the history
* fix: using index avoid uniqueid

* docs: add changelog

* Update CHANGELOG.md

* Update CHANGELOG.md

Co-authored-by: Larícia Mota <[email protected]>

Co-authored-by: Larícia Mota <[email protected]>
  • Loading branch information
emersonlaurentino and lariciamota authored Jul 28, 2022
1 parent a5662c9 commit 72476e4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed
- Quantity update by using item index instead of uniqueid

## [2.63.4] - 2022-05-24

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions react/ProductList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const ProductList: FC<Props> = ({ renderAsChildren, classes }) => {
const { handles } = useCssHandles(CSS_HANDLES, { classes })

const handleQuantityChange = useCallback(
(uniqueId: string, quantity: number, item: OrderFormItem) => {
(_: string, quantity: number, item: OrderFormItemWithIndex) => {
if (quantity === item.quantity) {
return
}
Expand Down Expand Up @@ -56,7 +56,7 @@ const ProductList: FC<Props> = ({ renderAsChildren, classes }) => {
})
}

updateQuantity({ uniqueId, quantity }, options)
updateQuantity({ index: item.index, quantity }, options)
},
[push, updateQuantity]
)
Expand Down
4 changes: 4 additions & 0 deletions react/typings/OrderForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ interface OrderFormItem {
parentItemIndex: number | null
}

interface OrderFormItemWithIndex extends OrderFormItem {
index: number
}

interface ItemAdditionalInfo {
brandName: string
}
Expand Down

0 comments on commit 72476e4

Please sign in to comment.