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
When displaying the same entity twice on the same page but in different view modes (e.g. full + teaser), then the contextual links of neither entity work.
Proposed resolution
TBD.
Debugging so far yielded this:
- each entity is assigned an entity instance ID correctly, each appears to be initialized correctly
- there is some double binding going on, which causes a click on the contextual links to call the click event handler twice, thus opening/closing it in quick succession, effectively making the contextual links seem broken (non-responsive)
- also see that only one of the two entities actually has an
EntityModel
inDrupal.quickedit.collections.entities.models
So likely the double-binding is due to the second entity not being handled correctly somewhere, likely in the final stages entity initialization.
Remaining tasks
Debug.
User interface changes
None.
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#8 | Screen Shot 2016-10-24 at 9.09.24 am.png | 286.94 KB | sittard |
#1 | reproduce-2466715-do-not-test.patch | 1.2 KB | Wim Leers |
#6 | Screen Shot 2016-08-11 at 1.32.08 pm.png | 120.6 KB | sittard |
#6 | Screen Shot 2016-08-11 at 1.11.38 pm.png | 105.87 KB | sittard |
Comments
Comment #1
Wim LeersComment #2
dawehnerI hope that patch isn't the proper fix :)
Comment #3
Wim LeersHaha, no, not at all! It's only to easily reproduce the problem, as the file name suggests.
If I'd actually propose this, I'd also give you the right to deny me french fries + mayonaise for the rest of my life :D
Comment #6
sittard CreditAttribution: sittard commentedThis bug or similar appears to be present in Drupal 8.2.1 and Drupal 8.3.x-dev
Steps to reproduce:
Attached are some screen shots to help highlight the issue.
Comment #7
BerdirIs the different view modes thing actually relevant? Doesn't it happen the same if you display it twice using the same view mode?
I know we fixed some bugs related to EntityModel when the same entity is present more than once on a page. We were running into that case for some of our sites.
Comment #8
sittard CreditAttribution: sittard commentedNo it would appear that the view mode is irrelevant. I recreated a page using the same view mode twice (see attached screenshot). But it appears just having a duplicate node on the screen is enough to disable the contextual menu functionality.
Comment #9
Wim LeersOnly once we have #2828528: Add Quick Edit Functional JS test coverage, we will be able to write sane test coverage. I've specifically thought about multiple instances in the test class, so that it's easy to add test coverage for this use case here.
Comment #11
geerlingguy CreditAttribution: geerlingguy at Acquia commentedJust spent an hour trying to track this down. In my case, I have a node rendered three times—teaser, contact, and accordion display modes—on one other referenced node's full view mode. I was banging my head against a wall seeing that all the markup was correct until I realized that if I rendered any of these three instances individually, everything worked great. But if I rendered two or more, none of the contextual buttons worked at all!
Other quickedit/contextual links are working fine on that same page, so luckily it's only the entity that's rendered three times that's breaking.
This is definitely a confusing behavior—is it possible we could get a fix in without waiting on a new testing system, if the fix can (for now, at least) be manually tested/verified? We could then open a follow-up issue to get a proper test in after #2828528: Add Quick Edit Functional JS test coverage is complete.
[Edit: A tiny bit more debugging found that the node being rendered three times would get entityInstanceID's of 0, then 0, then 1.]
Comment #12
geerlingguy CreditAttribution: geerlingguy at Acquia commentedSo... my particular problem was due to a bug in the Block Styles module (#2867873: Block Styles 'block--clean.html.twig' template doesn't print attributes, to be precise), and once I fixed that (made sure
attributes
were printed in it's custom block template), all the links worked great, and quirks went away.So I think this goes back (yet again) to #2551373: contextual.js and quickedit.js should fail gracefully, with useful error messages, when Twig templates forget to print attributes, which I think I've run into on every D8 site I've been involved with so far.
Comment #13
mlahde CreditAttribution: mlahde as a volunteer commentedJust checked that this still exists in 8.4.x-dev. Changed version status.
Comment #16
Wim Leers#2828528: Add Quick Edit Functional JS test coverage landed! Now tests are totally feasible to write. Let's get this done!
Comment #18
mcrittenden CreditAttribution: mcrittenden commentedFixing title to make it more clear that the issue is reproducible when using the same view mode rather than only being a problem when using different view modes.
Comment #25
SpokjeDue to Quickedit being moved out of Drupal Core and into a Contrib Module, moving this issue to the Contrib Module queue.