Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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:
- 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: Test
- Description:
Test with <a href="https://drupal.org">Link</a>
- 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
- Remove the wrapping anchor tag; Potentially cause a regression issue with #1488962: Increase touch target size of admin menu lists
- Sanitize the Description variable, removing anchor tags; Potentially reduce usability
- 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
Comment | File | Size | Author |
---|---|---|---|
#60 | 2688793-after-patch.png | 89.18 KB | pradipmodh13 |
#60 | 2688793-before-patch.png | 95.69 KB | pradipmodh13 |
#59 | After-patch.png | 157.51 KB | Sakthivel M |
#59 | Before-patch.png | 172.07 KB | Sakthivel M |
#59 | 2688793-Descriptions-containing-links-break-adminmenu-lists-59.patch | 2.48 KB | Sakthivel M |
Comments
Comment #2
Deciphered CreditAttribution: Deciphered at Realityloop commentedIssue appears to be limited to the Seven theme. Investigating further.
Comment #3
Deciphered CreditAttribution: Deciphered at Realityloop commentedSo 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 inseven_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.
Comment #4
therealssj CreditAttribution: therealssj commentedHow 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.
Comment #5
star-szrHmmmm.
Comment #6
star-szrI 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:
Comment #7
Deciphered CreditAttribution: Deciphered at Realityloop commentedComment #8
therealssj CreditAttribution: therealssj commentedThis is one way you can fix this.
Only for /node/add.
This is just a test. I might not have followed coding standards.
Comment #9
emma.mariaI can review and take a look at the coding standards.
Comment #16
Ajay.kumar CreditAttribution: Ajay.kumar at Srijan | A Material+ Company commentedSteps 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.
Comment #17
Ajay.kumar CreditAttribution: Ajay.kumar commentedSteps 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.
Comment #18
Ajay.kumar CreditAttribution: Ajay.kumar at Srijan | A Material+ Company commentedComment #19
gnuschichten CreditAttribution: gnuschichten at ETECTURE GmbH commentedI 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.
Comment #22
janmejaig CreditAttribution: janmejaig at Srijan | A Material+ Company for Drupal India Association commentedOn applying the patch #8 for Drupal 8.9.x it is getting fail , this needs to be reroll .
Comment #23
anushrikumari CreditAttribution: anushrikumari at OpenSense Labs commentedRerolled the patch for 8.9.x
Comment #24
anushrikumari CreditAttribution: anushrikumari at OpenSense Labs commentedComment #25
janmejaig CreditAttribution: janmejaig at Srijan | A Material+ Company for Drupal India Association commentedI have re-verified this issue and found that it is working fine without applying the patch for all the themes.
Comment #26
janmejaig CreditAttribution: janmejaig at Srijan | A Material+ Company for Drupal India Association commentedApology 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
Name: Test
Description: Test with Link
Comment #27
janmejaig CreditAttribution: janmejaig at Srijan | A Material+ Company for Drupal India Association commentedComment #28
Abhijith S CreditAttribution: Abhijith S as a volunteer and at Zyxware Technologies commentedApllied patch #23 .It works fine.
Adding screenshots
Before patch
After patch
RTBC
Comment #29
djsagar CreditAttribution: djsagar at OpenSense Labs commentedHere the Patch no 2688793-8.patch and 2688793-23.patch is not working, please see the attachment.
Comment #30
djsagar CreditAttribution: djsagar at OpenSense Labs commentedThe 2688793-23 patch is working that was some error i fond in my local, here the attachment as proof.
Comment #31
SpokjePatch #23 fails the Custom Commands phase and needs a reroll.
Comment #32
ankithashettyUpdated the patch in #23 to fix the custom test errors. Kindly review the following patch and interdiff.
Thank you!
Comment #33
SpokjeAlmost there, 3 more CSS-lint errors left.
Comment #34
anmolgoyal74 CreditAttribution: anmolgoyal74 at OpenSense Labs for DrupalFit commentedComment #35
BhumikaVarshney CreditAttribution: BhumikaVarshney as a volunteer and at OpenSense Labs commentedPatch #34, seems working fine and apply cleanly. Moving to RTBC +1. Added an after patch screenshot for reference.
Comment #36
IndrajithKB CreditAttribution: IndrajithKB at Srijan | A Material+ Company for Drupal India Association commentedComment #37
Madhu kumar CreditAttribution: Madhu kumar as a volunteer and at Zyxware Technologies commentedpatch #34 applied cleanly and working as expected, added screenshot for reference
Comment #38
Madhu kumar CreditAttribution: Madhu kumar as a volunteer and at Zyxware Technologies commentedComment #40
IndrajithKB CreditAttribution: IndrajithKB at Srijan | A Material+ Company for Drupal India Association commentedComment #41
IndrajithKB CreditAttribution: IndrajithKB at Srijan | A Material+ Company for Drupal India Association commentedRight 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
Comment #42
IndrajithKB CreditAttribution: IndrajithKB at Srijan | A Material+ Company for Drupal India Association commentedHi @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
SS after patch #34 - /admin/structure
SS after my fix:
Please check the patch with above mentioned pages too.
Comment #43
joachim CreditAttribution: joachim at Factorial GmbH commentedThe IS proposed resolution doesn't match what the patch is doing -- needs an update.
Comment #44
IndrajithKB CreditAttribution: IndrajithKB at Srijan | A Material+ Company for Drupal India Association commentedHi @joachim here we have anchor tag inside anchor tag.
please refer the link . That's why i used different method to resolve the issue.
Comment #45
chetanbharambe CreditAttribution: chetanbharambe at QED42 for Drupal India Association commentedComment #46
chetanbharambe CreditAttribution: chetanbharambe at QED42 for Drupal India Association commentedVerified 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
Comment #47
Sakthivel M CreditAttribution: Sakthivel M at QED42 for Drupal India Association commentedHi @Indrajith KB thanks for the #42 patch, it's working as expected.
Moved to RTBC
Comment #48
Sakthivel M CreditAttribution: Sakthivel M at QED42 for Drupal India Association commentedComment #49
quietone CreditAttribution: quietone as a volunteer commented@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.
Comment #50
vikashsoni CreditAttribution: vikashsoni as a volunteer and at Zyxware Technologies commentedI 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 .....
Comment #53
Harish1688 CreditAttribution: Harish1688 at Srijan | A Material+ Company commentedHi, 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.
Comment #54
Rakhi Soni CreditAttribution: Rakhi Soni at Smashing Infolabs Pvt. Ltd. for Smashing Infolabs Pvt. Ltd. commentedAttached rerolled patch against 9.5x branch,,
Kindly review patch,,
Comment #55
Munavijayalakshmi CreditAttribution: Munavijayalakshmi at Valuebound for Valuebound commentedRectified the following error.
themes/seven/css/components/admin-list.css
58:1 ✖ Unexpected missing end-of-source newline no-missing-end-of-source-newline
Comment #56
ambikahirode CreditAttribution: ambikahirode as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedPatch in #55 working fine for me on local 9.5
Comment #57
Munavijayalakshmi CreditAttribution: Munavijayalakshmi at Valuebound for Valuebound commentedAs per #56 screenshots problem resolved.
so changed to RTBC.
Comment #58
bnjmnmThis 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.
<a>
, and the CSS can be updated to fix any visual issues caused by that change.Comment #59
Sakthivel M CreditAttribution: Sakthivel M at QED42 for Drupal India Association commented#59 please review the patch
Before
After:
Comment #60
pradipmodh13 CreditAttribution: pradipmodh13 at Srijan | A Material+ Company for Drupal India Association commentedApplied patch #59. It is working as per expected behavior with existing content type and new content type.
Fot ref attached screenshot.
Comment #61
bnjmnm@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.
Comment #62
longwaveThe 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.