Problem/Motivation

If a content type description contains an <a> tag it results in a broken display of the Add content administration page when using the Seven theme.

Steps to reproduce:

  1. Spin up a sandbox site on SimplyTest.me: http://ply.st/drupal/8.0.x
  2. Install as Standard Drupal 8 profile with default configuration.
  3. Navigate to the Add content type page: admin/structure/types/add
  4. Add a new content type with the following settings:
    • Name: Test
    • Description: Test with <a href="https://drupal.org">Link</a>
  5. Navigate to the Add content page: node/add

This is present in the following templates:

  • admin-block-content.html.twig
  • block-content-add-list.html.twig
  • node-add-list.html.twig

The issue is due to the description variable being wrapped with an anchor tag, which causes the DOM to be re-arranged to comply with standards.

Proposed resolution

  1. Remove the wrapping anchor tag; Potentially cause a regression issue with #1488962: Increase touch target size of admin menu lists
  2. Sanitize the Description variable, removing anchor tags; Potentially reduce usability
  3. Replicate the wrapping anchor tag with Javascript; Potentially cause an issue for non-JS users

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#60 2688793-after-patch.png89.18 KBpradipmodh13
#60 2688793-before-patch.png95.69 KBpradipmodh13
#59 After-patch.png157.51 KBSakthivel M
#59 Before-patch.png172.07 KBSakthivel M
#59 2688793-Descriptions-containing-links-break-adminmenu-lists-59.patch2.48 KBSakthivel M
#56 Screenshot ..after_.patch.png364.26 KBambikahirode
#56 Screenshot ..before.patch.png442.78 KBambikahirode
#55 Descriptions-containing-links-break-admin-menu-lists-2688793-55.patch1.59 KBMunavijayalakshmi
#54 Descriptions-containing-links-break-admin-menu-lists-2688793-54.patch1.62 KBRakhi Soni
#53 2688793-After-patch-link.png114.8 KBHarish1688
#53 2688793-Before-patch-link.png123.39 KBHarish1688
#50 After--patch--pic.png24.28 KBvikashsoni
#50 Before--patch--pic.png26.2 KBvikashsoni
#47 After-patch.png113.75 KBSakthivel M
#47 Before-patch.png115.91 KBSakthivel M
#46 After Patch 2688793.png202.81 KBchetanbharambe
#46 Before Patch 2688793 up.png222.05 KBchetanbharambe
#42 interdiff_34-42.txt2.73 KBIndrajithKB
#42 2688793-after-fix.png24.37 KBIndrajithKB
#42 2688793-configuration.png95.19 KBIndrajithKB
#42 2688793-structure.png52.77 KBIndrajithKB
#42 2688793-42.patch1.59 KBIndrajithKB
#41 drupal-9.3.x.png26.28 KBIndrajithKB
#37 before-patch-contentype.png70.85 KBMadhu kumar
#37 after-patch-contentype.png65.03 KBMadhu kumar
#35 After-patch.png20.03 KBBhumikaVarshney
#34 interdiff_32_34.txt902 bytesanmolgoyal74
#34 2688793-34.patch2.62 KBanmolgoyal74
#32 interdiff_2688793_23-32.txt1.63 KBankithashetty
#32 2688793-32.patch2.62 KBankithashetty
#30 Screen Shot 2020-12-02 at 1.51.51 PM.png417.97 KBdjsagar
#29 Screen Shot 2020-12-02 at 12.16.01 PM.png25.61 KBdjsagar
#28 2688793-after_patch-#23.png20.44 KBAbhijith S
#28 2688793-before_patch-#23.png25.33 KBAbhijith S
#27 After applying patch.png35.24 KBjanmejaig
#26 Before applying Patch.png60.4 KBjanmejaig
#23 2688793-23.patch2.66 KBanushrikumari
#19 after-patch.png116.44 KBgnuschichten
#19 before-patch.png131.7 KBgnuschichten
#18 Links_Break.png85.12 KBAjay.kumar
#16 Links_Break.png85.12 KBAjay.kumar
#8 afterpatch.png86.24 KBtherealssj
#8 2688793-8.patch3 KBtherealssj
Add_content.png34.91 KBDeciphered
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Deciphered created an issue. See original summary.

Deciphered’s picture

Issue appears to be limited to the Seven theme. Investigating further.

Deciphered’s picture

So the issue is pretty straight forward:

Seven's version of node-add-list.html.twig Wraps the entire output of the page, label and description, with an <a> tag to make it all clickable. The result of this is any <a> tag in the description will cause the browser (in my case, Chrome) to re-structure the DOM to make the markup compliant (can't have an <a> inside an <a>).

The solution however is not so straight forward. Terminating the tag after the label (so it doesn't wrap the description) both effects the look of the page as well as the behaviour.

The simplest solution would be to strip the <a> tag from the Content type description in seven_preprocess_node_add_list(), however as user experience goes it is actually beneficial to be able to include links in a Content type description.

Opinions welcomed.

therealssj’s picture

How about we change the structure to be something like this https://jsfiddle.net/jvc16mqk/
Have an outer div and make entire div clickable with href of node/add.
Description will have a check, if it contains an anchor tag then put it outside the div and apply required formatting otherwise keep description inside div.

star-szr’s picture

Component: node system » Seven theme

Hmmmm.

star-szr’s picture

I suspect this applies to more than just /node/add (blocks as well?) based on the related issue. Based on a quick look I don't see links in the description being discussed there.

Edit: see these other templates:

  • admin-block-content.html.twig
  • block-content-add-list.html.twig
Deciphered’s picture

Title: Content Type description containing with <a> tag breaks Add content layout. » Descriptions containing links break admin menu lists.
Issue summary: View changes
therealssj’s picture

Status: Active » Needs review
FileSize
3 KB
86.24 KB

This is one way you can fix this.
Only for /node/add.
This is just a test. I might not have followed coding standards.

emma.maria’s picture

Issue tags: +CSS, +frontend, +Twig, +Seven

I can review and take a look at the coding standards.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Ajay.kumar’s picture

FileSize
85.12 KB

Steps to Replicate the Issue :

Spin up a sandbox site on SimplyTest.me: http://ply.st/drupal/8.0.x
Install as Standard Drupal 8 profile with default configuration.
Navigate to the Add content type page: admin/structure/types/add
Add a new content type with the following settings:
Name: drupal testing
Description: Test with Link
Navigate to the Add content page: node/add

The given bug /issue is already resolved. Please check the screenshot.

Only local images are allowed.

Ajay.kumar’s picture

Steps to Replicate the Issue :

Spin up a sandbox site on SimplyTest.me
Install as Standard Drupal 8 profile with default configuration.
Navigate to the Add content type page: admin/structure/types/add
Add a new content type with the following settings:
Name: drupal testing
Description: Test with Link
Navigate to the Add content page: node/add

The given issue is already resolved. Please check the screenshot below.

Ajay.kumar’s picture

FileSize
85.12 KB

screenshot

gnuschichten’s picture

FileSize
131.7 KB
116.44 KB

I can't confirm that the issue is resolved in 8.7.x. Links in the description field are still broken.

The patch #8 applies without errors against 8.7.x and fix the issue.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

janmejaig’s picture

Issue tags: +Needs reroll

On applying the patch #8 for Drupal 8.9.x it is getting fail , this needs to be reroll .

anushrikumari’s picture

FileSize
2.66 KB

Rerolled the patch for 8.9.x

anushrikumari’s picture

Issue tags: -Needs reroll
janmejaig’s picture

I have re-verified this issue and found that it is working fine without applying the patch for all the themes.

janmejaig’s picture

FileSize
60.4 KB

Apology for the last comment , I have re-check the issue by applying the patch #23 on drupal 8.9.x and found that it is working fine as expected. Please find the attachment for the same.

Steps To Test

    • Navigate to the Add content type page: admin/structure/types/add
    • Add a new content type with the following settings:
    • Name: Test
      Description: Test with Link

    • Navigate to the Add content page>click "Add Content" button
    • Observe the link and content
    janmejaig’s picture

    FileSize
    35.24 KB
    Abhijith S’s picture

    Apllied patch #23 .It works fine.
    Adding screenshots
    Before patch
    img
    After patch
    img2

    RTBC

    djsagar’s picture

    Status: Needs review » Needs work
    FileSize
    25.61 KB

    Here the Patch no 2688793-8.patch and 2688793-23.patch is not working, please see the attachment.

    djsagar’s picture

    Status: Needs work » Reviewed & tested by the community
    FileSize
    417.97 KB

    The 2688793-23 patch is working that was some error i fond in my local, here the attachment as proof.

    Spokje’s picture

    Status: Reviewed & tested by the community » Needs work
    Issue tags: +Needs reroll

    Patch #23 fails the Custom Commands phase and needs a reroll.

    ankithashetty’s picture

    Status: Needs work » Needs review
    Issue tags: -Needs reroll
    FileSize
    2.62 KB
    1.63 KB

    Updated the patch in #23 to fix the custom test errors. Kindly review the following patch and interdiff.

    Thank you!

    Spokje’s picture

    Status: Needs review » Needs work

    Almost there, 3 more CSS-lint errors left.

    anmolgoyal74’s picture

    Status: Needs work » Needs review
    FileSize
    2.62 KB
    902 bytes
    BhumikaVarshney’s picture

    FileSize
    20.03 KB

    Patch #34, seems working fine and apply cleanly. Moving to RTBC +1. Added an after patch screenshot for reference.

    IndrajithKB’s picture

    Assigned: Unassigned » IndrajithKB
    Madhu kumar’s picture

    patch #34 applied cleanly and working as expected, added screenshot for reference

    Madhu kumar’s picture

    Status: Needs review » Reviewed & tested by the community

    Status: Reviewed & tested by the community » Needs work

    The last submitted patch, 34: 2688793-34.patch, failed testing. View results

    IndrajithKB’s picture

    Assigned: IndrajithKB » Unassigned
    IndrajithKB’s picture

    Version: 8.9.x-dev » 9.3.x-dev
    FileSize
    26.28 KB

    Right now the patch #34 is failed and the issue is with 9.3.x also, so please re-roll the patch for D9 too.

    Am adding the SS from d9 and changing the issue tag to 9.3.x-dev

    image

    IndrajithKB’s picture

    Status: Needs work » Needs review
    FileSize
    1.59 KB
    52.77 KB
    95.19 KB
    24.37 KB
    2.73 KB

    Hi @anmolgoyal74 i have applied the patch and tested the other pages like /admin/structure, /admin/config and found the styles removed. So am adding new patch please review.

    SS after patch #34 - /admin/config
    image

    SS after patch #34 - /admin/structure
    image

    SS after my fix:
    image

    Please check the patch with above mentioned pages too.

    joachim’s picture

    The IS proposed resolution doesn't match what the patch is doing -- needs an update.

    IndrajithKB’s picture

    Hi @joachim here we have anchor tag inside anchor tag.

    nested a elements are forbidden in HTML syntax. HTML specifications do not say why; they just emphasize the rule.

    please refer the link . That's why i used different method to resolve the issue.

    chetanbharambe’s picture

    Assigned: Unassigned » chetanbharambe
    chetanbharambe’s picture

    Assigned: chetanbharambe » Unassigned
    FileSize
    222.05 KB
    202.81 KB

    Verified and tested patch #42.
    Patch applied successfully and looks good to me.

    Testing Steps:
    # Goto: admin/structure/types/manage/brand_page
    # Mention the Title Name
    # Mention the description - Test with <a href=“http://www.google.com”>link</a>
    # Save Content type
    # Goto: node/add
    # Check the created content type with description link.

    Expected Results:
    # Descriptions containing links should not be break admin menu lists.

    Actual Results:
    # Descriptions containing links break admin menu lists.

    Looks good to me.
    Need +1 RTBC

    Sakthivel M’s picture

    FileSize
    115.91 KB
    113.75 KB

    Hi @Indrajith KB thanks for the #42 patch, it's working as expected.

    Moved to RTBC

    Sakthivel M’s picture

    Status: Needs review » Reviewed & tested by the community
    quietone’s picture

    Status: Reviewed & tested by the community » Needs work

    @Sakthivel M, thanks for your interest in this issue. Having a working patch is not usually sufficient to mark an issue RTBC. There are several steps, or core gates that an issue must pass first. For this issue, an Issue Summary update was requested in #43 and that has not yet been complete. Since you have worked on the issue and are familiar with it you could address #43 and update the IS.

    Setting back to NW for an issue summary update.

    @Abhijith S, @dsagar @Sakthivel M, The screenshots added in #28, #29 and #47 are just after new screenshots in the previous comment and not adding to this issue. Therefor credit has been removed per How is credit granted for Drupal core issues.

    vikashsoni’s picture

    I have applied #42 patch
    patch working fine and applied successfully

    After patch the description field when we add a content looks good and in a proper format

    Thanks for the patch
    for ref sharing screenshot .....

    Version: 9.3.x-dev » 9.4.x-dev

    Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

    Version: 9.4.x-dev » 9.5.x-dev

    Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

    Harish1688’s picture

    Hi, tested the bug with version (9.4.x-dev and 9.5.x-dev) and its' still there.
    applied the patch 2688793-42.patch link styling in description field working fine, after patch.
    screenshot attached.

    Rakhi Soni’s picture

    Status: Needs work » Needs review
    FileSize
    1.62 KB

    Attached rerolled patch against 9.5x branch,,
    Kindly review patch,,

    Munavijayalakshmi’s picture

    Rectified the following error.

    themes/seven/css/components/admin-list.css
    58:1 ✖ Unexpected missing end-of-source newline no-missing-end-of-source-newline

    ambikahirode’s picture

    Patch in #55 working fine for me on local 9.5

    Munavijayalakshmi’s picture

    Assigned: Munavijayalakshmi » Unassigned
    Status: Needs review » Reviewed & tested by the community

    As per #56 screenshots problem resolved.
    so changed to RTBC.

    bnjmnm’s picture

    Status: Reviewed & tested by the community » Needs work
    • #42 still applied fine to 9.5, so the reroll in #54 was not necessary. Removing credit
      +++ b/core/themes/seven/templates/node-add-list.html.twig
      @@ -16,7 +16,17 @@
      +    {% set descLink = ('href' in type.description['#markup']) %}
      +      <li class="clearfix">
      +        <a href="{{ type.url }}"><span class="label">{{ type.label }}</span>
      +          {% if not descLink %}
      +            <div class="description">{{ type.description }}</div>
      +          {% endif %}
      +        </a>
      +        {% if descLink  %}
      +          <div class="description description-with-link">{{ type.description }}</div>
      +        {% endif %}
      

      This is clever but adds quite a bit of complexity for a very specific edge case. It would also return positive if the description had the string 'href' in it - whether or not it was a link.

    • This issue exposes an accessibility bug. The entire row is a link, but only the title is formatted to look like one. If you use a rotor the link text is extremely long and difficult to follow. The solution to the reported issue (links in descriptions look bad) should also fix the accessibility issue. Only the label should be wrapped in <a>, and the CSS can be updated to fix any visual issues caused by that change.
    Sakthivel M’s picture

    Status: Needs work » Needs review
    FileSize
    2.48 KB
    172.07 KB
    157.51 KB

    #59 please review the patch

    Before
    Image

    After:
    image

    pradipmodh13’s picture

    Applied patch #59. It is working as per expected behavior with existing content type and new content type.
    Fot ref attached screenshot.

    bnjmnm’s picture

    Status: Needs review » Needs work

    @pradipmodh13 screenshots were provided in the comment just above yours. Adding additional ones provides no benefit and adds noise to the issue. Pre-emptively removing credit.

    @Sakthivel M Without an interdiff it's not clear what the patch you added in #59 does differently. I can see, however, that my feedback in #58 was not addressed in it. The current solution with {% set descLink = ('href' in type.description['#markup']) %} and not something that would get committed to core.

    But seeing how Seven is being removed in Drupal 10 and will only exist as a contrib theme, maybe there will be more lenience to accepting these kind of solutions. Who knows.

    longwave’s picture

    Project: Drupal core » Seven
    Version: 9.5.x-dev » 1.0.0-alpha1
    Component: Seven theme » Code

    The Seven theme has been removed from Drupal 10 core. I confirmed that this issue only affects Seven and no other themes included with Drupal core, so I am moving this to the contributed Seven project.