woocommerce/plugins/woocommerce-blocks/assets/js/blocks/product-collection
Manish Menaria 8c284a5074
[Product Collection] Add unique ID attribute (#43314)
* Add unique ID attribute to Product Collection block

In this update, we introduced a unique identifier for each instance of the Product Collection block. This change involves several key modifications:

1. **Block JSON Update**: Added a new `id` attribute in `block.json` to store the unique identifier for each block instance.

2. **Product Collection Content Update**: In `product-collection-content.tsx`, we utilized the `uuid` library to generate a unique ID. This is done in a `useEffect` hook, ensuring that each block instance receives a distinct ID upon initialization.

3. **Type Definitions**: The `ProductCollectionAttributes` interface in `types.ts` was updated to include the new `id` attribute, aligning with our enhanced data structure.

4. **Package Dependencies**: To support this feature, `@types/uuid` and `uuid` were added to `package.json`, ensuring we have the necessary tools for ID generation.

This enhancement is pivotal for uniquely identifying each Product Collection block, paving the way for more robust and individualized block handling in the future.

* Rename uniqueId to id

* Add lock file

* Add 'id' context to product collection and template

* Add changefile(s) from automation for the following project(s): woocommerce-blocks

* Merge trunk with 42861-introduce-a-unique-identifier-for-each-product-collection-block

* Regenerate the lockfile

* Remove autogenerated change in plugins/woocommerce/package.json

* Regenerate lock file

* Rerun CI actions

* Delete pnpm-lock.yaml file & regenerate it using pnpm install command

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-01-18 15:30:57 +05:30
..
collections Product Collection: Make sure all variations are taken into account when choosing collection (#43273) 2024-01-08 10:55:42 +01:00
edit [Product Collection] Add unique ID attribute (#43314) 2024-01-18 15:30:57 +05:30
inner-blocks/no-results New flow of adding Product Collection and basic set of Collections (#42696) 2023-12-27 11:07:27 +01:00
variations Restructure Product Collection editor files (https://github.com/woocommerce/woocommerce-blocks/pull/11981) 2023-12-06 15:50:24 +01:00
block.json [Product Collection] Add unique ID attribute (#43314) 2024-01-18 15:30:57 +05:30
constants.ts Fix: Enable Pagination Block Visibility in Product Collection Block (#43132) 2023-12-29 15:45:29 +05:30
icon.tsx Foundation of New Product Collection Block (https://github.com/woocommerce/woocommerce-blocks/pull/9352) 2023-05-15 08:51:49 +00:00
index.tsx Fix: Enable Pagination Block Visibility in Product Collection Block (#43132) 2023-12-29 15:45:29 +05:30
save.tsx Foundation of New Product Collection Block (https://github.com/woocommerce/woocommerce-blocks/pull/9352) 2023-05-15 08:51:49 +00:00
types.ts [Product Collection] Add unique ID attribute (#43314) 2024-01-18 15:30:57 +05:30
utils.tsx Fix: Enable Pagination Block Visibility in Product Collection Block (#43132) 2023-12-29 15:45:29 +05:30