Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
vcanales authored and ntsekouras committed May 25, 2021
1 parent cb812df commit 63493a2
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions packages/block-library/src/navigation-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,19 @@ export default function NavigationLinkEdit( {
( kind && 'post-type' === kind ) || ( type && 'post' === type );

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

const { getEntityRecord } = select( coreStore );
const entityRecord = getEntityRecord( 'postType', type, id );

return entityRecord?.status;
}

return null;
} );
},
[ isPostType, type, id ]
);

// Check Navigation Link validity if:
// 1. Link is 'post-type'.
Expand All @@ -267,12 +270,7 @@ export default function NavigationLinkEdit( {
// 2. The Navigation Link item has no label.
// If either of those is true, invalidate.
const isInvalid =
isPostType &&
hasId &&
'undefined' !== typeof postStatus &&
null !== postStatus
? 'publish' !== postStatus || ! label
: false;
isPostType && hasId && postStatus && 'publish' !== postStatus;

const {
isAtMaxNesting,
Expand Down

0 comments on commit 63493a2

Please sign in to comment.