Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Fix: Use isEntityLink metadata for binding decisions in Navigation bl…
…ocks

- Updated Navigation Link and Navigation Submenu edit components to use isEntityLink metadata from updateAttributes
- Fixed menu-inspector-controls to use useEntityBinding hook for consistency
- Ensures bindings are only created for entity links (posts, pages, taxonomies)
- Prevents empty bindings from being created for custom links
- Fixes bug where severing entity links would incorrectly retain bindings
  • Loading branch information
getdave committed Oct 8, 2025
commit 800ec2cdd0f10eacda041dae517c4d14335f56d6
1 change: 0 additions & 1 deletion packages/block-library/src/navigation-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,6 @@ export default function NavigationLinkEdit( {
anchor={ popoverAnchor }
onRemove={ removeLink }
onChange={ ( updatedValue ) => {
// updateAttributes determines the final state and returns metadata
const { isEntityLink } = updateAttributes(
updatedValue,
setAttributes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ import { unlock } from '../../lock-unlock';
import DeletedNavigationWarning from './deleted-navigation-warning';
import useNavigationMenu from '../use-navigation-menu';
import LeafMoreMenu from './leaf-more-menu';
import { LinkUI, updateAttributes } from '../../navigation-link/shared';
import {
LinkUI,
updateAttributes,
useEntityBinding,
} from '../../navigation-link/shared';

const actionLabel =
/* translators: %s: The name of a menu. */ __( "Switch to '%s'" );
Expand All @@ -43,6 +47,12 @@ function AdditionalBlockContent( { block, insertedBlock, setInsertedBlock } ) {
const blockWasJustInserted = insertedBlock?.clientId === block.clientId;
const showLinkControls = supportsLinkControls && blockWasJustInserted;

// Get binding utilities for the inserted block
const { createBinding, clearBinding } = useEntityBinding( {
clientId: insertedBlock?.clientId,
attributes: insertedBlock?.attributes || {},
} );

if ( ! showLinkControls ) {
return null;
}
Expand Down Expand Up @@ -100,11 +110,22 @@ function AdditionalBlockContent( { block, insertedBlock, setInsertedBlock } ) {
cleanupInsertedBlock();
} }
onChange={ ( updatedValue ) => {
updateAttributes(
// updateAttributes determines the final state and returns metadata
const { isEntityLink } = updateAttributes(
updatedValue,
setInsertedBlockAttributes( insertedBlock?.clientId ),
insertedBlock?.attributes
);

// Handle URL binding based on the final computed state
// Only create bindings for entity links (posts, pages, taxonomies)
// Never create bindings for custom links (manual URLs)
if ( isEntityLink ) {
createBinding();
} else {
clearBinding();
}

setInsertedBlock( null );
} }
/>
Expand Down
Loading