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.
Sometimes we design a teaser view mode to wrap the entire content in an anchor element. For example:
<a href="/node/1">
<h2>Title</h2>
<div>Short description</div>
<img src="thumbnail.jpg" />
</a>
Contextual links inserts additional links inside this anchor. It is not valid HTML to have anchors inside anchors, and the contextual links do not work. For example:
<a href="/node/1">
<h2>Title</h2>
<div>Short description</div>
<img src="thumbnail.jpg" />
<button>Open configuration options</button>
<ul class="contextual-links">
<li><a href="#">Quick edit</a></li>
<li><a href="#">Edit</a></li>
<li><a href="#">Delete</a></li>
</ul>
</a>
I think the expected behaviour is that the contextual trigger and contextual links are not injected into the DOM if the contextual region is a descendent of an anchor.
Comment | File | Size | Author |
---|---|---|---|
#18 | Screenshot from 2021-07-15 15-41-45.png | 218.86 KB | dhirendra.mishra |
#18 | 2898875-18.patch | 1.37 KB | dhirendra.mishra |
#16 | contextual_links_should-2898875-16.patch | 1.37 KB | seanr |
#15 | contextual_links_should-2898875-15.patch | 1.21 KB | GRO |
#6 | contextual_links_should-2898875-6.patch | 1.58 KB | gargsuchi |
Comments
Comment #2
keeganstreet CreditAttribution: keeganstreet at Deloitte Digital commentedComment #3
keeganstreet CreditAttribution: keeganstreet at Deloitte Digital commentedAdded patch for 8.4.x which includes es6.js file.
Comment #6
gargsuchi CreditAttribution: gargsuchi at Salsa Digital for Department of Premier and Cabinet - Victoria, Australia commentedReroll attached against 8.5.x.
Comment #8
chOP CreditAttribution: chOP at Deloitte Digital commentedTime to test against latest dev branch.
Comment #12
gge CreditAttribution: gge commentedWith this patch blocks added using layout builder can't be edited anymore...
Comment #14
NWOM CreditAttribution: NWOM commentedSetting to NW due to the comment in #12.
Comment #15
GRO CreditAttribution: GRO commentedRe-rolled patch for Core 8.9
Comment #16
seanrAdded a patch against 9.2.x.
Comment #18
dhirendra.mishra CreditAttribution: dhirendra.mishra at Valuebound for Valuebound commentedRe-rolled it against 9.3.x and fixed on white-space issue which you can see in attached screenshot.
Comment #20
larowlanContextual links are controlled from your template.
If your template is outputting a wrapping link, you can simply choose not to output the title_suffix variable which renders the contextual link.