Skip to content

Commit 4da1896

Browse files
committed
Replace all navigation-id with router-region
1 parent 8ac17d9 commit 4da1896

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

plugins/woocommerce-blocks/assets/js/blocks/product-collection/frontend.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function scrollToFirstProductIfNotVisible( wcNavigationId?: string ) {
5252
return;
5353
}
5454

55-
const productSelector = `[data-wc-navigation-id=${ wcNavigationId }] .wc-block-product-template .wc-block-product`;
55+
const productSelector = `[data-wc-router-region=${ wcNavigationId }] .wc-block-product-template .wc-block-product`;
5656
const product = document.querySelector( productSelector );
5757
if ( product ) {
5858
const rect = product.getBoundingClientRect();
@@ -95,10 +95,10 @@ const productCollectionStore = {
9595
const ctx = getContext< ProductCollectionStoreContext >();
9696
const { ref } = getElement();
9797
const wcNavigationId = (
98-
ref?.closest( '[data-wc-navigation-id]' ) as HTMLDivElement
98+
ref?.closest( '[data-wc-router-region]' ) as HTMLDivElement
9999
)?.dataset?.wcNavigationId;
100100
const isDisabled = (
101-
ref?.closest( '[data-wc-navigation-id]' ) as HTMLDivElement
101+
ref?.closest( '[data-wc-router-region]' ) as HTMLDivElement
102102
)?.dataset.wcNavigationDisabled;
103103

104104
if ( isDisabled ) {
@@ -150,7 +150,7 @@ const productCollectionStore = {
150150
const { ref } = getElement();
151151

152152
const isDisabled = (
153-
ref?.closest( '[data-wc-navigation-id]' ) as HTMLDivElement
153+
ref?.closest( '[data-wc-router-region]' ) as HTMLDivElement
154154
)?.dataset.wcNavigationDisabled;
155155

156156
if ( isDisabled ) {
@@ -173,7 +173,7 @@ const productCollectionStore = {
173173
*prefetch() {
174174
const { ref } = getElement();
175175
const isDisabled = (
176-
ref?.closest( '[data-wc-navigation-id]' ) as HTMLDivElement
176+
ref?.closest( '[data-wc-router-region]' ) as HTMLDivElement
177177
)?.dataset.wcNavigationDisabled;
178178

179179
if ( isDisabled ) {

plugins/woocommerce/src/Blocks/BlockTypes/ProductCollection.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,10 @@ private function add_rendering_callback( $block_content, $collection ) {
294294
private function enable_client_side_navigation( $block_content ) {
295295
$p = new \WP_HTML_Tag_Processor( $block_content );
296296

297-
// Add `data-wc-navigation-id to the product collection block.
297+
// Add `data-wc-router-region to the product collection block.
298298
if ( $this->is_next_tag_product_collection( $p ) ) {
299299
$p->set_attribute(
300-
'data-wc-navigation-id',
300+
'data-wc-router-region',
301301
'wc-product-collection-' . $this->parsed_block['attrs']['queryId']
302302
);
303303
$current_context = json_decode( $p->get_attribute( 'data-wc-context' ) ?? '{}', true );

plugins/woocommerce/src/Blocks/BlockTypes/ProductFilter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ protected function render( $attributes, $content, $block ) {
121121
);
122122

123123
if ( ! isset( $block->context['queryId'] ) ) {
124-
$attributes_data['data-wc-navigation-id'] = $this->generate_navigation_id( $block );
124+
$attributes_data['data-wc-router-region'] = $this->generate_navigation_id( $block );
125125
}
126126

127127
$tags = new WP_HTML_Tag_Processor( $content );

plugins/woocommerce/src/Blocks/BlockTypes/ProductResultsCount.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected function render( $attributes, $content, $block ) {
5959
$p->set_attribute( 'class', implode( ' ', $classes ) );
6060
$p->set_attribute( 'style', $parsed_style_attributes['styles'] );
6161
$p->set_attribute(
62-
'data-wc-navigation-id',
62+
'data-wc-router-region',
6363
'wc-product-results-count-' . ( isset( $block->context['queryId'] ) ? $block->context['queryId'] : 0 )
6464
);
6565

0 commit comments

Comments
 (0)