From 67b3a6dfe1110451ffad1e6c542ad9691c64003f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Feb 2026 18:53:47 +0000 Subject: [PATCH 1/8] Initial plan From 138de82381d7f7183883a4c92453a182fb674622 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Feb 2026 18:55:54 +0000 Subject: [PATCH 2/8] Hide Link to control in sidebar when submenus open on click Co-authored-by: jeryj <967608+jeryj@users.noreply.github.com> --- .../src/navigation-link/shared/controls.js | 66 +++++++++++-------- .../src/navigation-submenu/edit.js | 1 + 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/packages/block-library/src/navigation-link/shared/controls.js b/packages/block-library/src/navigation-link/shared/controls.js index 907173cf533221..1b6d25f3e5fb2f 100644 --- a/packages/block-library/src/navigation-link/shared/controls.js +++ b/packages/block-library/src/navigation-link/shared/controls.js @@ -72,12 +72,18 @@ function getEntityTypeName( type, kind ) { * This component provides the inspector controls (ToolsPanel) that are identical * between both navigation blocks. * - * @param {Object} props - Component props - * @param {Object} props.attributes - Block attributes - * @param {Function} props.setAttributes - Function to update block attributes - * @param {string} props.clientId - Block client ID + * @param {Object} props - Component props + * @param {Object} props.attributes - Block attributes + * @param {Function} props.setAttributes - Function to update block attributes + * @param {string} props.clientId - Block client ID + * @param {boolean} props.openSubmenusOnClick - Whether submenus open on click (for Submenu blocks only) */ -export function Controls( { attributes, setAttributes, clientId } ) { +export function Controls( { + attributes, + setAttributes, + clientId, + openSubmenusOnClick = false, +} ) { const { label, url, description, rel, opensInNewTab } = attributes; const dropdownMenuProps = useToolsPanelDropdownMenuProps(); @@ -188,32 +194,34 @@ export function Controls( { attributes, setAttributes, clientId } ) { /> - !! url } - label={ __( 'Link to' ) } - onDeselect={ () => - setAttributes( { - url: undefined, - id: undefined, - kind: undefined, - type: undefined, - } ) - } - isShownByDefault - > - !! url } label={ __( 'Link to' ) } - help={ helpText ? helpText : undefined } - /> - + onDeselect={ () => + setAttributes( { + url: undefined, + id: undefined, + kind: undefined, + type: undefined, + } ) + } + isShownByDefault + > + + + ) } - { url && ( + { url && ! openSubmenusOnClick && (
From 3e0ee029687ecccbf522ad99e1fe9e76ed01dd0b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Feb 2026 19:02:18 +0000 Subject: [PATCH 3/8] Add tests for openSubmenusOnClick prop in Controls component Co-authored-by: jeryj <967608+jeryj@users.noreply.github.com> --- .../navigation-link/shared/test/controls.js | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/packages/block-library/src/navigation-link/shared/test/controls.js b/packages/block-library/src/navigation-link/shared/test/controls.js index 1e92c5b7a67dc5..d9fe0a65ad7ecc 100644 --- a/packages/block-library/src/navigation-link/shared/test/controls.js +++ b/packages/block-library/src/navigation-link/shared/test/controls.js @@ -304,4 +304,53 @@ describe( 'Controls', () => { expect( screen.getByText( 'View link' ) ).toBeVisible(); } ); } ); + + describe( 'openSubmenusOnClick prop', () => { + it( 'hides Link to control when openSubmenusOnClick is true', () => { + const propsWithOpenOnClick = { + ...defaultProps, + openSubmenusOnClick: true, + }; + + render( ); + + // Link to control should not be visible + expect( screen.queryByText( 'Link to' ) ).not.toBeInTheDocument(); + + // Other controls should still be visible + expect( screen.getByLabelText( 'Text' ) ).toBeInTheDocument(); + expect( + screen.getByLabelText( 'Open in new tab' ) + ).toBeInTheDocument(); + expect( + screen.getByLabelText( 'Description' ) + ).toBeInTheDocument(); + expect( + screen.getByLabelText( 'Rel attribute' ) + ).toBeInTheDocument(); + } ); + + it( 'shows Link to control when openSubmenusOnClick is false (default)', () => { + render( ); + + // Link to control should be visible + expect( screen.getByText( 'Link to' ) ).toBeInTheDocument(); + } ); + + it( 'hides View/Edit buttons when openSubmenusOnClick is true', () => { + const propsWithUrl = { + ...defaultProps, + openSubmenusOnClick: true, + attributes: { + ...defaultProps.attributes, + url: 'https://example.com', + }, + }; + + render( ); + + // View button should not be visible + expect( screen.queryByText( 'View link' ) ).not.toBeInTheDocument(); + } ); + } ); } ); From 5e0f6de2395896ee88adbbd8b3a6bedbc92e2ecb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Feb 2026 19:03:39 +0000 Subject: [PATCH 4/8] Fix JSDoc alignment in controls.js Co-authored-by: jeryj <967608+jeryj@users.noreply.github.com> --- .../src/navigation-link/shared/controls.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/block-library/src/navigation-link/shared/controls.js b/packages/block-library/src/navigation-link/shared/controls.js index 1b6d25f3e5fb2f..a6d87e74cbc129 100644 --- a/packages/block-library/src/navigation-link/shared/controls.js +++ b/packages/block-library/src/navigation-link/shared/controls.js @@ -72,11 +72,11 @@ function getEntityTypeName( type, kind ) { * This component provides the inspector controls (ToolsPanel) that are identical * between both navigation blocks. * - * @param {Object} props - Component props - * @param {Object} props.attributes - Block attributes - * @param {Function} props.setAttributes - Function to update block attributes - * @param {string} props.clientId - Block client ID - * @param {boolean} props.openSubmenusOnClick - Whether submenus open on click (for Submenu blocks only) + * @param {Object} props - Component props + * @param {Object} props.attributes - Block attributes + * @param {Function} props.setAttributes - Function to update block attributes + * @param {string} props.clientId - Block client ID + * @param {boolean} props.openSubmenusOnClick - Whether submenus open on click (for Submenu blocks only) */ export function Controls( { attributes, From 1577e0711352f4a02293f50717fd9b8c4fa3514f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Feb 2026 19:18:02 +0000 Subject: [PATCH 5/8] Rename prop from openSubmenusOnClick to isLinkEditable Co-authored-by: jeryj <967608+jeryj@users.noreply.github.com> --- .../src/navigation-link/shared/controls.js | 16 ++++++++-------- .../src/navigation-link/shared/test/controls.js | 16 ++++++++-------- .../block-library/src/navigation-submenu/edit.js | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/block-library/src/navigation-link/shared/controls.js b/packages/block-library/src/navigation-link/shared/controls.js index a6d87e74cbc129..bd69f8c0833287 100644 --- a/packages/block-library/src/navigation-link/shared/controls.js +++ b/packages/block-library/src/navigation-link/shared/controls.js @@ -72,17 +72,17 @@ function getEntityTypeName( type, kind ) { * This component provides the inspector controls (ToolsPanel) that are identical * between both navigation blocks. * - * @param {Object} props - Component props - * @param {Object} props.attributes - Block attributes - * @param {Function} props.setAttributes - Function to update block attributes - * @param {string} props.clientId - Block client ID - * @param {boolean} props.openSubmenusOnClick - Whether submenus open on click (for Submenu blocks only) + * @param {Object} props - Component props + * @param {Object} props.attributes - Block attributes + * @param {Function} props.setAttributes - Function to update block attributes + * @param {string} props.clientId - Block client ID + * @param {boolean} props.isLinkEditable - Whether link editing should be allowed */ export function Controls( { attributes, setAttributes, clientId, - openSubmenusOnClick = false, + isLinkEditable = true, } ) { const { label, url, description, rel, opensInNewTab } = attributes; const dropdownMenuProps = useToolsPanelDropdownMenuProps(); @@ -194,7 +194,7 @@ export function Controls( { /> - { ! openSubmenusOnClick && ( + { isLinkEditable && ( !! url } label={ __( 'Link to' ) } @@ -221,7 +221,7 @@ export function Controls( { ) } - { url && ! openSubmenusOnClick && ( + { url && isLinkEditable && ( { } ); } ); - describe( 'openSubmenusOnClick prop', () => { - it( 'hides Link to control when openSubmenusOnClick is true', () => { - const propsWithOpenOnClick = { + describe( 'isLinkEditable prop', () => { + it( 'hides Link to control when isLinkEditable is false', () => { + const propsWithNonEditableLink = { ...defaultProps, - openSubmenusOnClick: true, + isLinkEditable: false, }; - render( ); + render( ); // Link to control should not be visible expect( screen.queryByText( 'Link to' ) ).not.toBeInTheDocument(); @@ -330,17 +330,17 @@ describe( 'Controls', () => { ).toBeInTheDocument(); } ); - it( 'shows Link to control when openSubmenusOnClick is false (default)', () => { + it( 'shows Link to control when isLinkEditable is true (default)', () => { render( ); // Link to control should be visible expect( screen.getByText( 'Link to' ) ).toBeInTheDocument(); } ); - it( 'hides View/Edit buttons when openSubmenusOnClick is true', () => { + it( 'hides View/Edit buttons when isLinkEditable is false', () => { const propsWithUrl = { ...defaultProps, - openSubmenusOnClick: true, + isLinkEditable: false, attributes: { ...defaultProps.attributes, url: 'https://example.com', diff --git a/packages/block-library/src/navigation-submenu/edit.js b/packages/block-library/src/navigation-submenu/edit.js index 7c6326878c3afe..69644a3d5121a0 100644 --- a/packages/block-library/src/navigation-submenu/edit.js +++ b/packages/block-library/src/navigation-submenu/edit.js @@ -340,7 +340,7 @@ export default function NavigationSubmenuEdit( { attributes={ attributes } setAttributes={ setAttributes } clientId={ clientId } - openSubmenusOnClick={ openSubmenusOnClick } + isLinkEditable={ ! openSubmenusOnClick } />
From ab4e301f0c298b8245220c3d56dada246be902de Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Feb 2026 19:24:16 +0000 Subject: [PATCH 6/8] Nest Edit/View buttons inside isLinkEditable conditional Co-authored-by: jeryj <967608+jeryj@users.noreply.github.com> --- .../src/navigation-link/shared/controls.js | 148 +++++++++--------- 1 file changed, 75 insertions(+), 73 deletions(-) diff --git a/packages/block-library/src/navigation-link/shared/controls.js b/packages/block-library/src/navigation-link/shared/controls.js index bd69f8c0833287..28c9385f81f019 100644 --- a/packages/block-library/src/navigation-link/shared/controls.js +++ b/packages/block-library/src/navigation-link/shared/controls.js @@ -195,84 +195,86 @@ export function Controls( { { isLinkEditable && ( - !! url } - label={ __( 'Link to' ) } - onDeselect={ () => - setAttributes( { - url: undefined, - id: undefined, - kind: undefined, - type: undefined, - } ) - } - isShownByDefault - > - + !! url } label={ __( 'Link to' ) } - help={ helpText ? helpText : undefined } - /> - - ) } + onDeselect={ () => + setAttributes( { + url: undefined, + id: undefined, + kind: undefined, + type: undefined, + } ) + } + isShownByDefault + > + + - { url && isLinkEditable && ( - - { hasUrlBinding && - isBoundEntityAvailable && - entityRecord?.id && - attributes.kind === 'post-type' && - onNavigateToEntityRecord && ( - - ) } - { isViewableUrl && ( - + ) } + { isViewableUrl && ( + ) } - + ) } - + ) } Date: Tue, 17 Feb 2026 19:32:48 +0000 Subject: [PATCH 7/8] Remove tests for isLinkEditable prop Co-authored-by: jeryj <967608+jeryj@users.noreply.github.com> --- .../navigation-link/shared/test/controls.js | 49 ------------------- 1 file changed, 49 deletions(-) diff --git a/packages/block-library/src/navigation-link/shared/test/controls.js b/packages/block-library/src/navigation-link/shared/test/controls.js index 7bf106985cf1a6..1e92c5b7a67dc5 100644 --- a/packages/block-library/src/navigation-link/shared/test/controls.js +++ b/packages/block-library/src/navigation-link/shared/test/controls.js @@ -304,53 +304,4 @@ describe( 'Controls', () => { expect( screen.getByText( 'View link' ) ).toBeVisible(); } ); } ); - - describe( 'isLinkEditable prop', () => { - it( 'hides Link to control when isLinkEditable is false', () => { - const propsWithNonEditableLink = { - ...defaultProps, - isLinkEditable: false, - }; - - render( ); - - // Link to control should not be visible - expect( screen.queryByText( 'Link to' ) ).not.toBeInTheDocument(); - - // Other controls should still be visible - expect( screen.getByLabelText( 'Text' ) ).toBeInTheDocument(); - expect( - screen.getByLabelText( 'Open in new tab' ) - ).toBeInTheDocument(); - expect( - screen.getByLabelText( 'Description' ) - ).toBeInTheDocument(); - expect( - screen.getByLabelText( 'Rel attribute' ) - ).toBeInTheDocument(); - } ); - - it( 'shows Link to control when isLinkEditable is true (default)', () => { - render( ); - - // Link to control should be visible - expect( screen.getByText( 'Link to' ) ).toBeInTheDocument(); - } ); - - it( 'hides View/Edit buttons when isLinkEditable is false', () => { - const propsWithUrl = { - ...defaultProps, - isLinkEditable: false, - attributes: { - ...defaultProps.attributes, - url: 'https://example.com', - }, - }; - - render( ); - - // View button should not be visible - expect( screen.queryByText( 'View link' ) ).not.toBeInTheDocument(); - } ); - } ); } ); From 9b4fd7ed40dc24d4e9582ce71f1738d4e881f61a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Feb 2026 20:29:03 +0000 Subject: [PATCH 8/8] Hide "Open in new tab" when links are not editable Co-authored-by: jeryj <967608+jeryj@users.noreply.github.com> --- .../src/navigation-link/shared/controls.js | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/packages/block-library/src/navigation-link/shared/controls.js b/packages/block-library/src/navigation-link/shared/controls.js index 28c9385f81f019..54f48cb7bdb906 100644 --- a/packages/block-library/src/navigation-link/shared/controls.js +++ b/packages/block-library/src/navigation-link/shared/controls.js @@ -274,24 +274,26 @@ export function Controls( { ) } ) } + + !! opensInNewTab } + label={ __( 'Open in new tab' ) } + onDeselect={ () => + setAttributes( { opensInNewTab: false } ) + } + isShownByDefault + > + + setAttributes( { opensInNewTab: value } ) + } + /> + ) } - !! opensInNewTab } - label={ __( 'Open in new tab' ) } - onDeselect={ () => setAttributes( { opensInNewTab: false } ) } - isShownByDefault - > - - setAttributes( { opensInNewTab: value } ) - } - /> - - !! description } label={ __( 'Description' ) }