Problem/Motivation

When editing, the summary or editing shows this:
"entity:node/246"
That's a major UX issue as i have a hard time to understand what this is linked to.
I either need to save and find the link (although i don't know what label to search for) and klick to the target, or maybe copy parts like node/246 into the address toolbar.

Proposed resolution

Add a link in the summary.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork paragraphs-3124166

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yongt9412 created an issue. See original summary.

johnchque’s picture

Status: Active » Needs review
FileSize
921 bytes
14.97 KB

Not fixing tests yet. I thought that an icon might add too much visual noise as a square icon in the middle of the summary feels like some action to take.
Instead I tried by adding the link in the title or uri if they exist.

Status: Needs review » Needs work

The last submitted patch, 2: unclear-links-3124166-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

johnchque’s picture

Status: Needs work » Needs review
FileSize
1.27 KB
441 bytes

Forgot this.

Status: Needs review » Needs work

The last submitted patch, 4: unclear-links-3124166-4.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Berdir’s picture

Issue tags: +Needs tests
+++ b/src/Entity/Paragraph.php
@@ -511,12 +512,13 @@ class Paragraph extends ContentEntityBase implements ParagraphInterface {
 
       if ($field_definition->getType() == 'link') {
         if (!empty($this->get($field_name)->first())) {
+          $url = Url::fromUri($this->get($field_name)->uri)->toString();
           // If title is not set, fallback to the uri.
           if ($title = $this->get($field_name)->title) {
-            $summary['content'][] = $title;
+            $summary['content'][] = ['#markup' => '<a href="' . $url . '">' . $title . '</a>'];
           }
           else {
-            $summary['content'][] = $this->get($field_name)->uri;
+            $summary['content'][] = ['#markup' => '<a href="' . $url . '">' . $url . '</a>'];
           }
         }

The Url::fromUri() call might fail, we should wrap that in a try/catch.

Also, LinkItem, which is returned by the first() call has getUrl(), which should make it a little bit easier.

I'm not sure if we really to show it as a link, if yes then possibly add target _blank, so it opens in a new tab? we don't want users to lose their data if they click on such a link.

Needs test fixes and maybe also improved test coverage for this.

weekbeforenext made their first commit to this issue’s fork.

weekbeforenext’s picture

This is great! I refactored a little to go a step further and use an entity label if possible.