Skip to content

Commit

Permalink
Fix the Query block when navigating
Browse files Browse the repository at this point in the history
  • Loading branch information
DAreRodz committed Jan 31, 2024
1 parent 249ce2e commit e82e7c5
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions packages/block-library/src/query/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ store( 'core/query', {
*navigate( event ) {
const ctx = getContext();
const { ref } = getElement();
const { queryRef } = ctx;
const queryRef = ref.closest(
'.wp-block-query[data-wp-router-region]'
);
const isDisabled = queryRef?.dataset.wpNavigationDisabled;

if ( isValidLink( ref ) && isValidEvent( event ) && ! isDisabled ) {
Expand Down Expand Up @@ -67,8 +69,10 @@ store( 'core/query', {
}
},
*prefetch() {
const { queryRef } = getContext();
const { ref } = getElement();
const queryRef = ref.closest(
'.wp-block-query[data-wp-router-region]'
);
const isDisabled = queryRef?.dataset.wpNavigationDisabled;
if ( isValidLink( ref ) && ! isDisabled ) {
const { actions } = yield import(
Expand All @@ -89,10 +93,5 @@ store( 'core/query', {
yield actions.prefetch( ref.href );
}
},
setQueryRef() {
const ctx = getContext();
const { ref } = getElement();
ctx.queryRef = ref;
},
},
} );

0 comments on commit e82e7c5

Please sign in to comment.