Skip to content

Commit

Permalink
Block Editor: Link Control: Use URL as link when title empty (#19739)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth authored Jan 20, 2020
1 parent a016b31 commit 49cd963
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/block-editor/src/components/link-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ import { noop, startsWith } from 'lodash';
import { Button, ExternalLink, VisuallyHidden } from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';
import { useCallback, useState, Fragment } from '@wordpress/element';

import {
safeDecodeURI,
filterURLForDisplay,
isURL,
prependHTTP,
getProtocol,
} from '@wordpress/url';

import { useInstanceId } from '@wordpress/compose';
import { useSelect } from '@wordpress/data';

Expand All @@ -44,6 +42,7 @@ function LinkControl( {
fetchSearchSuggestions: getSettings().__experimentalFetchLinkSuggestions,
};
}, [] );
const displayURL = ( value && filterURLForDisplay( safeDecodeURI( value.url ) ) ) || '';

/**
* onChange LinkControlSearchInput event handler
Expand Down Expand Up @@ -175,9 +174,13 @@ function LinkControl( {
className="block-editor-link-control__search-item-title"
href={ value.url }
>
{ value.title }
{ ( value && value.title ) || displayURL }
</ExternalLink>
<span className="block-editor-link-control__search-item-info">{ filterURLForDisplay( safeDecodeURI( value.url ) ) || '' }</span>
{ value && value.title && (
<span className="block-editor-link-control__search-item-info">
{ displayURL }
</span>
) }
</span>

<Button
Expand Down

0 comments on commit 49cd963

Please sign in to comment.