woocommerce/plugins/woocommerce-blocks/assets/js/blocks/product-collection/edit
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
..
inspector-controls Product Collection: Rename "Inherit query from template" option and make description contextual (#43270) 2024-01-10 12:40:05 +01:00
toolbar-controls New flow of adding Product Collection and basic set of Collections (#42696) 2023-12-27 11:07:27 +01:00
collection-chooser.tsx New flow of adding Product Collection and basic set of Collections (#42696) 2023-12-27 11:07:27 +01:00
collection-selection-modal.tsx New flow of adding Product Collection and basic set of Collections (#42696) 2023-12-27 11:07:27 +01:00
editor.scss Fix incorrect layout of Product Collection placeholder on Firefox (#43264) 2024-01-04 11:20:57 +01:00
index.tsx New flow of adding Product Collection and basic set of Collections (#42696) 2023-12-27 11:07:27 +01:00
product-collection-content.tsx [Product Collection] Add unique ID attribute (#43314) 2024-01-18 15:30:57 +05:30
product-collection-placeholder.tsx New flow of adding Product Collection and basic set of Collections (#42696) 2023-12-27 11:07:27 +01:00