Skip to content

Commit 87d0bc1

Browse files
Infinite-NullInfinite-Nullt-hamano
authored
Navigation Submenu Link: Add Open in new tab toggle to navigation block sidebar (#70687)
* feat: Add 'Open in new tab' option to Navigation Submenu block * Set default value for opensInNewTab in NavigationSubmenuEdit Co-authored-by: Infinite-Null <ankitkumarshah@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org>
1 parent 90adbe9 commit 87d0bc1

File tree

1 file changed

+21
-1
lines changed
  • packages/block-library/src/navigation-submenu

1 file changed

+21
-1
lines changed

packages/block-library/src/navigation-submenu/edit.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import clsx from 'clsx';
88
*/
99
import { useSelect, useDispatch } from '@wordpress/data';
1010
import {
11+
CheckboxControl,
1112
TextControl,
1213
TextareaControl,
1314
ToolbarButton,
@@ -134,7 +135,7 @@ export default function NavigationSubmenuEdit( {
134135
context,
135136
clientId,
136137
} ) {
137-
const { label, url, description, rel } = attributes;
138+
const { label, url, description, rel, opensInNewTab } = attributes;
138139

139140
const { showSubmenuIcon, maxNestingLevel, openSubmenusOnClick } = context;
140141

@@ -392,6 +393,7 @@ export default function NavigationSubmenuEdit( {
392393
url: '',
393394
description: '',
394395
rel: '',
396+
opensInNewTab: false,
395397
} );
396398
} }
397399
dropdownMenuProps={ dropdownMenuProps }
@@ -433,6 +435,24 @@ export default function NavigationSubmenuEdit( {
433435
/>
434436
</ToolsPanelItem>
435437

438+
<ToolsPanelItem
439+
hasValue={ () => !! opensInNewTab }
440+
label={ __( 'Open in new tab' ) }
441+
onDeselect={ () =>
442+
setAttributes( { opensInNewTab: false } )
443+
}
444+
isShownByDefault
445+
>
446+
<CheckboxControl
447+
__nextHasNoMarginBottom
448+
label={ __( 'Open in new tab' ) }
449+
checked={ opensInNewTab }
450+
onChange={ ( value ) =>
451+
setAttributes( { opensInNewTab: value } )
452+
}
453+
/>
454+
</ToolsPanelItem>
455+
436456
<ToolsPanelItem
437457
label={ __( 'Description' ) }
438458
isShownByDefault

0 commit comments

Comments
 (0)