Skip to content

Commit

Permalink
Remove duplicated display URL in LinkControl (#53167)
Browse files Browse the repository at this point in the history
* Remove duplicated display URL in LinkControl

* update block-editor-link-control__search-item-title line-height

* update styles
  • Loading branch information
ntsekouras authored Aug 2, 2023
1 parent 5898968 commit b340afd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ export default function LinkPreview( {
( value && filterURLForDisplay( safeDecodeURI( value.url ), 16 ) ) ||
'';

const displayTitle = richData?.title || value?.title || displayURL;

// url can be undefined if the href attribute is unset
const isEmptyURL = ! value?.url?.length;

const displayTitle =
! isEmptyURL &&
stripHTML( richData?.title || value?.title || displayURL );

let icon;

if ( richData?.icon ) {
Expand Down Expand Up @@ -87,10 +89,10 @@ export default function LinkPreview( {
className="block-editor-link-control__search-item-title"
href={ value.url }
>
{ stripHTML( displayTitle ) }
{ displayTitle }
</ExternalLink>

{ value?.url && (
{ value?.url && displayTitle !== displayURL && (
<span className="block-editor-link-control__search-item-info">
{ displayURL }
</span>
Expand Down
3 changes: 2 additions & 1 deletion packages/block-editor/src/components/link-control/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ $preview-image-height: 140px;

.block-editor-link-control__search-item-title {
display: block;
margin-bottom: 0.2em;
font-weight: 500;
position: relative;
line-height: $grid-unit-30;

mark {
font-weight: 600;
Expand Down Expand Up @@ -291,6 +291,7 @@ $preview-image-height: 140px;
display: flex;
flex-direction: row;
width: 100%; // clip.
align-items: center;
}

.block-editor-link-control__search-item-bottom {
Expand Down

0 comments on commit b340afd

Please sign in to comment.