Skip to content

Commit

Permalink
Bail out in prefetch if clientNavigation is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
DAreRodz committed Feb 7, 2024
1 parent c411dd6 commit ca35dd7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 1 addition & 5 deletions packages/block-library/src/query/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
Expand Down
3 changes: 3 additions & 0 deletions packages/interactivity-router/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
Expand Down

0 comments on commit ca35dd7

Please sign in to comment.