Commit 0c4a1a225b for woocommerce
commit 0c4a1a225b3123962a2f1168ff5b2d1a52b22ee9
Author: Karol Manijak <20098064+kmanijak@users.noreply.github.com>
Date: Fri Nov 28 14:32:31 2025 +0100
Don't display deprecation notice while using deprecated Navigation store internally (#62049)
* Remove auto usage of deprecated API by Woo itself
* Add chanbgelog
* Add data changelog
* Revert "Remove auto usage of deprecated API by Woo itself"
This reverts commit e5fdb800797b27b64b03f24ad8c29641731f1fca.
* Extend the deprecation notice supression
* Apply more robust way of recognizing internal function call with Symbol
* Move INTERNAL_CALL symbol so it's not exposed externally
diff --git a/packages/js/data/changelog/fix-62029 b/packages/js/data/changelog/fix-62029
new file mode 100644
index 0000000000..e93cf6da1c
--- /dev/null
+++ b/packages/js/data/changelog/fix-62029
@@ -0,0 +1,4 @@
+Significance: minor
+Type: update
+
+Navigation store: don't call deprecated onHistoryChange
diff --git a/packages/js/data/src/navigation/dispatchers.ts b/packages/js/data/src/navigation/dispatchers.ts
index 62cc877f14..64cd4ab59b 100644
--- a/packages/js/data/src/navigation/dispatchers.ts
+++ b/packages/js/data/src/navigation/dispatchers.ts
@@ -9,14 +9,21 @@ import { addHistoryListener } from '@woocommerce/navigation';
*/
import { STORE_NAME } from './constants';
+export const INTERNAL_CALL = Symbol( 'INTERNAL_CALL' );
export default async () => {
const { onLoad, onHistoryChange } = dispatch( STORE_NAME );
- await onLoad();
+ // @ts-expect-error onLoad accepts no parameters, but we pass INTERNAL_CALL
+ // to suppress deprecation warnings for internal usage. The wrapper in index.ts
+ // handles this symbol to skip the deprecation message.
+ await onLoad( INTERNAL_CALL );
addHistoryListener( async () => {
setTimeout( async () => {
- await onHistoryChange();
+ // @ts-expect-error onHistoryChange accepts no parameters, but we pass INTERNAL_CALL
+ // to suppress deprecation warnings for internal usage. The wrapper in index.ts
+ // handles this symbol to skip the deprecation message.
+ await onHistoryChange( INTERNAL_CALL );
}, 0 );
} );
};
diff --git a/packages/js/data/src/navigation/index.ts b/packages/js/data/src/navigation/index.ts
index 3cc344db76..e6c1f1e591 100644
--- a/packages/js/data/src/navigation/index.ts
+++ b/packages/js/data/src/navigation/index.ts
@@ -14,7 +14,7 @@ import * as selectors from './selectors';
import * as actions from './actions';
import reducer, { State } from './reducer';
import * as resolvers from './resolvers';
-import initDispatchers from './dispatchers';
+import initDispatchers, { INTERNAL_CALL } from './dispatchers';
import { WPDataActions, WPDataSelectors } from '../types';
import { PromiseifySelectors } from '../types/promiseify-selectors';
@@ -27,8 +27,14 @@ function wrapWithDeprecate< T extends Record< string, unknown > >( obj: T ): T {
const value = obj[ key ];
if ( typeof value === 'function' ) {
wrapped[ key ] = function ( this: unknown, ...args: unknown[] ) {
- // onLoad action is automatically called when initDispatchers is called, skip deprecation message.
- if ( key !== 'onLoad' ) {
+ // Skip deprecation message for:
+ // - onLoad (automatically called by initDispatchers)
+ // - onHistoryChange when called internally with true flag
+ const shouldSkipDeprecation =
+ ( key === 'onLoad' || key === 'onHistoryChange' ) &&
+ args[ 0 ] === INTERNAL_CALL;
+
+ if ( ! shouldSkipDeprecation ) {
deprecated( 'Navigation store', {} );
}
return ( value as ( ...args: unknown[] ) => unknown ).apply(
diff --git a/plugins/woocommerce/changelog/fix-62029 b/plugins/woocommerce/changelog/fix-62029
new file mode 100644
index 0000000000..ed5c96a289
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-62029
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Navigation store: don't call deprecated onHistoryChange