From 7bd713c5ed802e15a81e83e7b4dd74e04488f9de Mon Sep 17 00:00:00 2001 From: Tung Du Date: Thu, 24 Oct 2024 13:44:03 +0700 Subject: [PATCH] Experimental: Prevent diffing error using key for each router region of Chips and Checkbox List (#52210) --- .../changelog/fix-checkbox-list-chip-diffing-error | 5 +++++ .../src/Blocks/BlockTypes/ProductFilterCheckboxList.php | 1 + .../woocommerce/src/Blocks/BlockTypes/ProductFilterChips.php | 1 + 3 files changed, 7 insertions(+) create mode 100644 plugins/woocommerce/changelog/fix-checkbox-list-chip-diffing-error diff --git a/plugins/woocommerce/changelog/fix-checkbox-list-chip-diffing-error b/plugins/woocommerce/changelog/fix-checkbox-list-chip-diffing-error new file mode 100644 index 00000000000..4835bbb5942 --- /dev/null +++ b/plugins/woocommerce/changelog/fix-checkbox-list-chip-diffing-error @@ -0,0 +1,5 @@ +Significance: patch +Type: fix +Comment: Experimental: Fix diffing error for Checkbox List and Chips blocks. + + diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterCheckboxList.php b/plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterCheckboxList.php index 9cc900a4952..0a6cd957c05 100644 --- a/plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterCheckboxList.php +++ b/plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterCheckboxList.php @@ -55,6 +55,7 @@ final class ProductFilterCheckboxList extends AbstractBlock { $wrapper_attributes = array( 'data-wc-interactive' => esc_attr( $namespace ), 'data-wc-context' => wp_json_encode( $checkbox_list_context, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP ), + 'data-wc-key' => wp_unique_prefixed_id( $this->get_full_block_name() ), 'class' => esc_attr( $classes ), 'style' => esc_attr( $style ), ); diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterChips.php b/plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterChips.php index dec171c98f9..638ca6e218b 100644 --- a/plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterChips.php +++ b/plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterChips.php @@ -54,6 +54,7 @@ final class ProductFilterChips extends AbstractBlock { $wrapper_attributes = array( 'data-wc-interactive' => esc_attr( $namespace ), 'data-wc-context' => wp_json_encode( $checkbox_list_context, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP ), + 'data-wc-key' => wp_unique_prefixed_id( $this->get_full_block_name() ), 'class' => esc_attr( $classes ), 'style' => esc_attr( $style ), );