From ca35dd7c09f355d53d48332ef7ff1e44887fc015 Mon Sep 17 00:00:00 2001 From: David Arenas Date: Wed, 7 Feb 2024 16:55:04 +0100 Subject: [PATCH] Bail out in prefetch if clientNavigation is disabled --- packages/block-library/src/query/view.js | 6 +----- packages/interactivity-router/src/index.js | 3 +++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/block-library/src/query/view.js b/packages/block-library/src/query/view.js index 987fa8ea07a497..e23294a24e02e3 100644 --- a/packages/block-library/src/query/view.js +++ b/packages/block-library/src/query/view.js @@ -45,11 +45,7 @@ store( }, *prefetch() { const { ref } = getElement(); - const queryRef = ref.closest( - '.wp-block-query[data-wp-router-region]' - ); - const isDisabled = queryRef?.dataset.wpNavigationDisabled; - if ( isValidLink( ref ) && ! isDisabled ) { + if ( isValidLink( ref ) ) { const { actions } = yield import( '@wordpress/interactivity-router' ); diff --git a/packages/interactivity-router/src/index.js b/packages/interactivity-router/src/index.js index 87b34cee8a1edc..0e7a930141ecfb 100644 --- a/packages/interactivity-router/src/index.js +++ b/packages/interactivity-router/src/index.js @@ -225,6 +225,9 @@ export const { state, actions } = store( 'core/router', { * fetching the requested URL. */ prefetch( url, options = {} ) { + const { clientNavigation = true } = getConfig( 'core/router' ); + if ( ! clientNavigation ) return; + const pagePath = getPagePath( url ); if ( options.force || ! pages.has( pagePath ) ) { pages.set( pagePath, fetchPage( pagePath, options ) );