diff --git a/packages/block-editor/src/components/link-control/style.scss b/packages/block-editor/src/components/link-control/style.scss index d8c21f3b88be20..6650cb7c98f20c 100644 --- a/packages/block-editor/src/components/link-control/style.scss +++ b/packages/block-editor/src/components/link-control/style.scss @@ -241,13 +241,17 @@ $block-editor-link-control-number-of-actions: 1; } .block-editor-link-control__settings { - border-top: 1px solid $gray-300; + border-top: $border-width solid $gray-300; margin: 0; padding: $grid-unit-20 $grid-unit-30; :last-child { margin-bottom: 0; } + + .is-alternate & { + border-top: $border-width solid $gray-900; + } } .block-editor-link-control__setting { diff --git a/packages/block-editor/src/components/url-input/index.js b/packages/block-editor/src/components/url-input/index.js index 4e9e59322e9f50..401f64ede229d2 100644 --- a/packages/block-editor/src/components/url-input/index.js +++ b/packages/block-editor/src/components/url-input/index.js @@ -100,6 +100,7 @@ class URLInput extends Component { } componentWillUnmount() { + this.suggestionsRequest?.cancel?.(); delete this.suggestionsRequest; } diff --git a/packages/block-library/src/navigation-link/edit.js b/packages/block-library/src/navigation-link/edit.js index c6dd37884807ed..7b1892b67e2322 100644 --- a/packages/block-library/src/navigation-link/edit.js +++ b/packages/block-library/src/navigation-link/edit.js @@ -309,6 +309,10 @@ export default function NavigationLinkEdit( { }, } ); + if ( ! url ) { + blockProps.onClick = () => setIsLinkOpen( true ); + } + const innerBlocksProps = useInnerBlocksProps( { className: classnames( 'wp-block-navigation__container', { @@ -332,6 +336,33 @@ export default function NavigationLinkEdit( { } ); + const classes = classnames( 'wp-block-navigation-link__content', { + 'wp-block-navigation-link__placeholder': ! url, + } ); + + let missingText = ''; + switch ( type ) { + case 'post': + /* translators: label for missing post in navigation link block */ + missingText = __( 'Select a post' ); + break; + case 'page': + /* translators: label for missing page in navigation link block */ + missingText = __( 'Select a page' ); + break; + case 'category': + /* translators: label for missing category in navigation link block */ + missingText = __( 'Select a category' ); + break; + case 'tag': + /* translators: label for missing tag in navigation link block */ + missingText = __( 'Select a tag' ); + break; + default: + /* translators: label for missing values in navigation link block */ + missingText = __( 'Add a link' ); + } + return ( @@ -389,38 +420,61 @@ export default function NavigationLinkEdit( {
  • -
    - - setAttributes( { label: labelValue } ) - } - onMerge={ mergeBlocks } - onReplace={ onReplace } - __unstableOnSplitAtEnd={ () => - insertBlocksAfter( - createBlock( 'core/navigation-link' ) - ) - } - aria-label={ __( 'Navigation link text' ) } - placeholder={ itemLabelPlaceholder } - keepPlaceholderOnFocus - withoutInteractiveFormatting - allowedFormats={ [ - 'core/bold', - 'core/italic', - 'core/image', - 'core/strikethrough', - ] } - /> +
    + { ! url ? ( +
    + + isSelected && setIsLinkOpen( true ), + } } + /> + { missingText } +
    + ) : ( + + setAttributes( { label: labelValue } ) + } + onMerge={ mergeBlocks } + onReplace={ onReplace } + __unstableOnSplitAtEnd={ () => + insertBlocksAfter( + createBlock( 'core/navigation-link' ) + ) + } + aria-label={ __( 'Navigation link text' ) } + placeholder={ itemLabelPlaceholder } + keepPlaceholderOnFocus + withoutInteractiveFormatting + allowedFormats={ [ + 'core/bold', + 'core/italic', + 'core/image', + 'core/strikethrough', + ] } + onClick={ () => { + if ( ! url ) { + setIsLinkOpen( true ); + } + } } + /> + ) } { isLinkOpen && ( setIsLinkOpen( false ) } > + setIsLinkOpen( false ), + } } + />