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

Nor4a created an issue. See original summary.

Nor4a’s picture

cilefen’s picture

Status: Active » Needs review
Issue tags: +JavaScript
Related issues: +#2743353: Contextual links double trigger

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

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now 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.

hampercm’s picture

Status: Needs review » Needs work
+++ b/core/modules/contextual/js/contextual.js
@@ -157,6 +157,7 @@
+        if ($.inArray($(this).attr('data-contextual-id'), ids) < 0)
         ids.push($(this).attr('data-contextual-id'));

Drupal 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...

DamienMcKenna’s picture

Status: Needs work » Needs review
FileSize
726 bytes
795 bytes

Syntax fixes, as requested.

Wim Leers’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

AFAICT this is not possible, because:

var $placeholders = $context.find('[data-contextual-id]').once('contextual-render');

That should ensure each of these is processed only once. So this needs a test to show how/when this breaks.