Commit 4bbe1425b8 for woocommerce
commit 4bbe1425b806b2007cb8d212d69503c6dd7c58d6
Author: Luis Herranz <luisherranz@gmail.com>
Date: Fri Feb 13 14:06:53 2026 +0100
iAPI: Remove `needsRefreshForInteractivityAPI` in favor of `core/router`'s `clientNavigationDisabled` (#63230)
* Remove needsRefreshForInteractivityAPI in favor of clientNavigationDisabled
* Add changefile(s) from automation for the following project(s): woocommerce
---------
Co-authored-by: woocommercebot <woocommercebot@users.noreply.github.com>
diff --git a/plugins/woocommerce/changelog/63230-iapi-remove-needsrefreshforinteractivityapi-in-favor-of-clientnavigationdisabled b/plugins/woocommerce/changelog/63230-iapi-remove-needsrefreshforinteractivityapi-in-favor-of-clientnavigationdisabled
new file mode 100644
index 0000000000..7e36611714
--- /dev/null
+++ b/plugins/woocommerce/changelog/63230-iapi-remove-needsrefreshforinteractivityapi-in-favor-of-clientnavigationdisabled
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+
+Replace custom `needsRefreshForInteractivityAPI` with native `clientNavigationDisabled` from WordPress core's Interactivity Router.
\ No newline at end of file
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/__tests__/frontend.test.ts b/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/__tests__/frontend.test.ts
index e2223c06f6..7821ab1a0d 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/__tests__/frontend.test.ts
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/__tests__/frontend.test.ts
@@ -133,13 +133,6 @@ describe( 'product filters interactivity store', () => {
if ( key === 'woocommerce/product-filters' ) {
return {
canonicalUrl,
- isProductArchive: true,
- };
- }
- if ( key === 'woocommerce' ) {
- return {
- isBlockTheme: true,
- needsRefreshForInteractivityAPI: false,
};
}
return {};
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/frontend.ts b/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/frontend.ts
index 991657863b..374cd63fc3 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/frontend.ts
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/frontend.ts
@@ -227,21 +227,6 @@ const productFiltersStore = {
return;
}
- const sharedSettings = getConfig( 'woocommerce' );
- const productFilterSettings = getConfig( BLOCK_NAME );
- const isBlockTheme = sharedSettings?.isBlockTheme || false;
- const isProductArchive =
- productFilterSettings?.isProductArchive || false;
- const needsRefreshForInteractivityAPI =
- sharedSettings?.needsRefreshForInteractivityAPI || false;
-
- if (
- needsRefreshForInteractivityAPI ||
- ( ! isBlockTheme && isProductArchive )
- ) {
- return ( window.location.href = url.href );
- }
-
const routerModule: typeof import('@wordpress/interactivity-router') =
yield import( '@wordpress/interactivity-router' );
diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/ClassicTemplate.php b/plugins/woocommerce/src/Blocks/BlockTypes/ClassicTemplate.php
index 3b0137a1dc..af0695adc9 100644
--- a/plugins/woocommerce/src/Blocks/BlockTypes/ClassicTemplate.php
+++ b/plugins/woocommerce/src/Blocks/BlockTypes/ClassicTemplate.php
@@ -50,12 +50,12 @@ class ClassicTemplate extends AbstractDynamicBlock {
protected function enqueue_data( array $attributes = array() ) {
parent::enqueue_data( $attributes );
- // Indicate to interactivity powered components that this block is on the page
- // and needs refresh to update data.
+ // Disable client-side navigation so that interactivity powered
+ // components fall back to full page reload.
wp_interactivity_config(
- 'woocommerce',
+ 'core/router',
array(
- 'needsRefreshForInteractivityAPI' => true,
+ 'clientNavigationDisabled' => true,
)
);
}
diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/ProductFilters.php b/plugins/woocommerce/src/Blocks/BlockTypes/ProductFilters.php
index 36d1d6380b..9f1827095c 100644
--- a/plugins/woocommerce/src/Blocks/BlockTypes/ProductFilters.php
+++ b/plugins/woocommerce/src/Blocks/BlockTypes/ProductFilters.php
@@ -41,12 +41,12 @@ class ProductFilters extends AbstractBlock {
BlocksSharedState::load_store_config( 'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WooCommerce' );
- wp_interactivity_config(
- $this->get_full_block_name(),
- [
- 'isProductArchive' => is_shop() || is_product_taxonomy() || ( is_search() && 'product' === get_post_type() ),
- ]
- );
+ // Classic themes do not support client-side navigation on product
+ // archive pages, so disable it globally for the Interactivity Router.
+ $is_product_archive = is_shop() || is_product_taxonomy() || ( is_search() && 'product' === get_post_type() );
+ if ( ! wp_is_block_theme() && $is_product_archive ) {
+ wp_interactivity_config( 'core/router', array( 'clientNavigationDisabled' => true ) );
+ }
}
/**
diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/ProductQuery.php b/plugins/woocommerce/src/Blocks/BlockTypes/ProductQuery.php
index ba4c0d7de5..68f0b068e1 100644
--- a/plugins/woocommerce/src/Blocks/BlockTypes/ProductQuery.php
+++ b/plugins/woocommerce/src/Blocks/BlockTypes/ProductQuery.php
@@ -180,12 +180,12 @@ class ProductQuery extends AbstractBlock {
$this->parsed_block = $parsed_block;
if ( self::is_woocommerce_variation( $parsed_block ) ) {
- // Indicate to interactivity powered components that this block is on the page
- // and needs refresh to update data.
+ // Disable client-side navigation so that interactivity powered
+ // components fall back to full page reload.
wp_interactivity_config(
- 'woocommerce',
+ 'core/router',
[
- 'needsRefreshForInteractivityAPI' => true,
+ 'clientNavigationDisabled' => true,
]
);
// Set this so that our product filters can detect if it's a PHP template.
diff --git a/plugins/woocommerce/src/Blocks/Utils/BlocksSharedState.php b/plugins/woocommerce/src/Blocks/Utils/BlocksSharedState.php
index 5518e42e98..8904a863d7 100644
--- a/plugins/woocommerce/src/Blocks/Utils/BlocksSharedState.php
+++ b/plugins/woocommerce/src/Blocks/Utils/BlocksSharedState.php
@@ -87,7 +87,6 @@ class BlocksSharedState {
wp_interactivity_config( self::$settings_namespace, self::get_currency_data() );
wp_interactivity_config( self::$settings_namespace, self::get_locale_data() );
- wp_interactivity_config( self::$settings_namespace, self::get_core_data() );
}
/**
@@ -126,17 +125,6 @@ class BlocksSharedState {
}
}
- /**
- * Get core data to include in settings.
- *
- * @return array
- */
- private static function get_core_data(): array {
- return array(
- 'isBlockTheme' => wp_is_block_theme(),
- );
- }
-
/**
* Get currency data to include in settings.
*