Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation Link: Add "Open in new tab" toggle to navigation block sidebar #67262

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from
Open
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
Next Next commit
Navigation: Add "Open in new tab" toggle to navigation block sidebar
Infinite-Null committed Nov 25, 2024
commit 9143aae125a421f8476f66e5e698af65a2073651
13 changes: 12 additions & 1 deletion packages/block-library/src/navigation-link/edit.js
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ import {
ToolbarButton,
Tooltip,
ToolbarGroup,
ToggleControl,
} from '@wordpress/components';
import { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';
import { __ } from '@wordpress/i18n';
@@ -159,9 +160,19 @@ function getMissingText( type ) {
* Consider reuseing this components for both blocks.
*/
function Controls( { attributes, setAttributes, setIsLabelFieldFocused } ) {
const { label, url, description, title, rel } = attributes;
const { label, url, description, title, rel, opensInNewTab } = attributes;
return (
<PanelBody title={ __( 'Settings' ) }>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Open in new tab' ) }
help={ __( 'The link will open in a new tab when clicked.' ) }
checked={ opensInNewTab }
onChange={ () =>
setAttributes( { opensInNewTab: ! opensInNewTab } )
}
/>

<TextControl
__nextHasNoMarginBottom
__next40pxDefaultSize