diff --git a/packages/block-library/src/post-author-name/edit.js b/packages/block-library/src/post-author-name/edit.js index 2b4bb0709356b0..8c0281edb5df8a 100644 --- a/packages/block-library/src/post-author-name/edit.js +++ b/packages/block-library/src/post-author-name/edit.js @@ -15,7 +15,16 @@ import { import { useSelect } from '@wordpress/data'; import { __, sprintf } from '@wordpress/i18n'; import { store as coreStore } from '@wordpress/core-data'; -import { PanelBody, ToggleControl } from '@wordpress/components'; +import { + ToggleControl, + __experimentalToolsPanel as ToolsPanel, + __experimentalToolsPanelItem as ToolsPanelItem, +} from '@wordpress/components'; + +/** + * Internal dependencies + */ +import { useToolsPanelDropdownMenuProps } from '../utils/hooks'; function PostAuthorNameEdit( { context: { postType, postId }, @@ -61,6 +70,8 @@ function PostAuthorNameEdit( { displayName ); + const dropdownMenuProps = useToolsPanelDropdownMenuProps(); + return ( <> @@ -72,26 +83,53 @@ function PostAuthorNameEdit( { /> - - { + setAttributes( { + isLink: false, + linkTarget: '_self', + } ); + } } + dropdownMenuProps={ dropdownMenuProps } + > + setAttributes( { isLink: ! isLink } ) } - checked={ isLink } - /> - { isLink && ( + isShownByDefault + hasValue={ () => isLink } + onDeselect={ () => setAttributes( { isLink: false } ) } + > - setAttributes( { - linkTarget: value ? '_blank' : '_self', - } ) + label={ __( 'Link to author archive' ) } + onChange={ () => + setAttributes( { isLink: ! isLink } ) } - checked={ linkTarget === '_blank' } + checked={ isLink } /> + + { isLink && ( + linkTarget !== '_self' } + onDeselect={ () => + setAttributes( { linkTarget: '_self' } ) + } + > + + setAttributes( { + linkTarget: value ? '_blank' : '_self', + } ) + } + checked={ linkTarget === '_blank' } + /> + ) } - +
{ supportsAuthor