From 7f59f6985b7917986ee7cc32e5d401e8538a6c13 Mon Sep 17 00:00:00 2001 From: yashjawale Date: Mon, 16 Feb 2026 10:48:31 +0100 Subject: [PATCH 1/7] refactor: use private store for internal navigation properties and deprecate direct access --- packages/interactivity-router/src/index.ts | 35 ++++++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/packages/interactivity-router/src/index.ts b/packages/interactivity-router/src/index.ts index af7efcdaf29098..704ba739f3766a 100644 --- a/packages/interactivity-router/src/index.ts +++ b/packages/interactivity-router/src/index.ts @@ -394,14 +394,43 @@ interface Store { }; } -export const { state, actions } = store< Store >( 'core/router', { +interface PrivateStore { + state: { + navigation: { + hasStarted: boolean; + hasFinished: boolean; + }; + }; +} + +// Create the private store for internal navigation properties +const { state: privateState } = store< PrivateStore >( 'core/router/private', { state: { - url: window.location.href, navigation: { hasStarted: false, hasFinished: false, }, }, +} ); + +export const { state, actions } = store< Store >( 'core/router', { + state: { + url: window.location.href, + get navigation() { + // Deprecation warning for hasStarted and hasFinished properties. + // TODO: Remove this in a future version. + if ( + typeof window !== 'undefined' && + window.console && + window.console.warn + ) { + window.console.warn( + 'core/router store navigation.hasStarted and navigation.hasFinished properties are part of the private API and its usage is discouraged.' + ); + } + return privateState.navigation; + }, + }, actions: { /** * Navigates to the specified page. @@ -428,7 +457,7 @@ export const { state, actions } = store< Store >( 'core/router', { } const pagePath = getPagePath( href ); - const { navigation } = state; + const { navigation } = privateState; const { loadingAnimation = true, screenReaderAnnouncement = true, From e205c412bab1409de2c0f396e27ac85be1879cc6 Mon Sep 17 00:00:00 2001 From: luisherranz Date: Mon, 16 Feb 2026 10:50:23 +0100 Subject: [PATCH 2/7] Add changelog --- packages/interactivity-router/CHANGELOG.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/interactivity-router/CHANGELOG.md b/packages/interactivity-router/CHANGELOG.md index d79a1e4f8046e5..4e220a6726dc2d 100644 --- a/packages/interactivity-router/CHANGELOG.md +++ b/packages/interactivity-router/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Deprecations + +- Move `state.navigation.hasStarted` and `state.navigation.hasFinished` to a private store and deprecate direct access from the public `core/router` store. ([#70882](https://github.com/WordPress/gutenberg/pull/70882)) + ### Bug Fixes - Update cached styles for re-fetched pages. ([#75097](https://github.com/WordPress/gutenberg/pull/75097)) @@ -41,8 +45,7 @@ - Preserve `media` attribute on intial style sheets after client-side navigation. ([70668](https://github.com/WordPress/gutenberg/pull/70668)) -- Ignores `