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

LinkControl: refine the display of the link preview title and url #60900

Closed
afercia opened this issue Apr 19, 2024 · 1 comment · Fixed by #61819
Closed

LinkControl: refine the display of the link preview title and url #60900

afercia opened this issue Apr 19, 2024 · 1 comment · Fixed by #61819
Assignees
Labels
[Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) [Package] Block editor /packages/block-editor [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.

Comments

@afercia
Copy link
Contributor

afercia commented Apr 19, 2024

Description

Normally, the LinkControl 'link preview' displayes two lines:

  1. the displayTitle, which can be a few things:
  • the document title of the fetched 'rich data' of the link destination page
  • or, the entered link text
  • or, the entered link URL
  1. The displayURL which is the link URL, with the protocol part stripped out.

When the rich data info can not be fetched, the 'title' is, normally, the linked text. Screenshot:

normally

When the link text is the same as the displayURL, there is some logic in place to avoid to display two lines with the same identical information. That makes totally sense, and only one line is displayed. Screenshot:

Screenshot 2024-04-19 at 14 03 49

Without this logic, there would be two lines that would repeat the same, identical, information. Screenshot:

otherwise

So far, so good.

However, the logic in place doesn't take into account the case when the link text contains the protocol. In this case, the preview displayes both lines and they contain the same information, the only difference is the displayed protocol. Screenshot:

Screenshot 2024-04-19 at 14 04 09

Visually and semantically, in this case the repeated information is redundant. It would be best to show only the displayTitle.

Step-by-step reproduction instructions

  • Add a Paragraph that contains the text test.org.
  • Select the text test.org and add a link to test.org without the protocol part.
  • Once the link is added, click the link in the Paragraph to open the link control preview.
  • Observe the link preview displays only one line: test.org.
  • Add a Paragraph with some text and paste https://test.org within the text. The pasted link should be automatically transformed to a link. If not, make sure to add a link to it with the value https://test.org. It doesn't matter whether the URL contains the protocol part.
  • Once the link is added, click the link in the Paragraph to open the link control preview.
  • Observe the link preview displays two lines: https://test.org and test.org.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@amitraj2203
Copy link
Contributor

Hi @afercia, For this issue I have raised a PR.
I have added the logic to check weather the URL and text (after removing the protocol from the text) is same or not. If its the same then we are going to show only the displayTitle.

@afercia afercia added the [Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) label May 29, 2024
@afercia afercia assigned afercia and amitraj2203 and unassigned afercia May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) [Package] Block editor /packages/block-editor [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
None yet
2 participants