Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Sometimes other modules makes markup that rises javascript to "double-trigger" the contextual links popup event. Which leads that the contextual links popup does not appear. For example it is happening when using Panels (https://www.drupal.org/node/2743353).
The simple patch below fixes the problem.
Comments
Comment #2
Nor4a CreditAttribution: Nor4a as a volunteer commentedComment #3
cilefen CreditAttribution: cilefen commentedComment #5
hampercm CreditAttribution: hampercm as a volunteer and at Acquia commentedDrupal coding standards require code blocks attached to if statements and loops to be surrounded by curly braces ({}), even if they're one line. Code blocks also must be indented. See https://www.drupal.org/docs/develop/standards/javascript/javascript-codi...
Comment #6
DamienMcKennaSyntax fixes, as requested.
Comment #7
Wim LeersAFAICT this is not possible, because:
That should ensure each of these is processed only once. So this needs a test to show how/when this breaks.
Comment #9
JacobSanford@DamienMcKenna's patch in #6 no longer applied to 8.5.x. A reroll with no further modifications is attached.
Comment #10
Anonymous (not verified) CreditAttribution: Anonymous commentedI ran into this effect. But #7 remark from Wim Leers led to an additional investigation. It is very likely, that the reason for the double trigger is the same ids of contextual links. I posted a patch in the issue describing it (#2891603-5: Contextual links can't handle multiple occurrences of the same contextual links (again)).
Comment #12
2phaI have just come across this, Contextual links not opening.
What I have found is that....
One first page load they open and work fine.
One subsequent page loads, they do not open (but events are fired as I can see some classes being changed).
Under "Session Storage" in Chrome, you can see some "Drupal.contextual" items, when you delete these and reload the page, the contextual links will work again (but again, only for that page load, not subsequent page loads).
The contextual links that don't open for me are on titles output by a view.
The above fix / patches did not work for me.
Comment #14
Ludo.RPatch #6 and #9 didn't work for me as well
Comment #16
komejo CreditAttribution: komejo at ThinkShout commentedMost current patch that fixes this is here: Contextual links can't handle multiple occurrences of the same contextual links (again)
Comment #18
kerasai CreditAttribution: kerasai at Hook 42 commentedAt some point the data structure changed from just an array of the string IDs to an array of objects. Here is an updated version of the patch that adds an array to track which IDs have been seen, and returning early to avoid the double processing.
Applies cleanly to 8.7, 8.8, and 8.9.
Comment #19
kerasai CreditAttribution: kerasai at Hook 42 commentedUghh, missed a line from moving my own hacking into the existing approach.
Updated patch attached.
Comment #23
u_tiwari CreditAttribution: u_tiwari as a volunteer commentedRe-rolled for 9.3
Comment #24
u_tiwari CreditAttribution: u_tiwari as a volunteer commentedRe-rolled for 9.2
Comment #26
larowlanCan you please provide steps to reproduce, starting from 'install drupal'.
Cheers
Comment #30
smustgrave CreditAttribution: smustgrave at Mobomo commentedThank you everyone on this.
If still a valid bug please reopen adding steps to reproduce
Thanks