Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Navigation Link: Don't check validity when block editing is disabled (#…
…69627)

Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
  • Loading branch information
3 people authored and t-hamano committed Jun 30, 2025
commit 8410f6303be0cf31b1762284f80848e3fb3f72d1
13 changes: 12 additions & 1 deletion packages/block-library/src/navigation-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
store as blockEditorStore,
getColorClassName,
useInnerBlocksProps,
useBlockEditingMode,
} from '@wordpress/block-editor';
import { isURL, prependHTTP, safeDecodeURI } from '@wordpress/url';
import { useState, useEffect, useRef } from '@wordpress/element';
Expand Down Expand Up @@ -99,15 +100,25 @@ const useIsInvalidLink = ( kind, type, id ) => {
const isPostType =
kind === 'post-type' || type === 'post' || type === 'page';
const hasId = Number.isInteger( id );
const blockEditingMode = useBlockEditingMode();

const postStatus = useSelect(
( select ) => {
if ( ! isPostType ) {
return null;
}

// Fetching the posts status is an "expensive" operation. Especially for sites with large navigations.
// When the block is rendered in a template or other disabled contexts we can skip this check in order
// to avoid all these additional requests that don't really add any value in that mode.
if ( blockEditingMode === 'disabled' ) {
return null;
}

const { getEntityRecord } = select( coreStore );
return getEntityRecord( 'postType', type, id )?.status;
},
[ isPostType, type, id ]
[ isPostType, blockEditingMode, type, id ]
);

// Check Navigation Link validity if:
Expand Down