Symptoms
Clicking on component selection checkbox includes the component visually, but does not have the checkbox checked.

Problem
Component selection checkbox has it's 'onclick' handler applied multiple times if any other module calls Drupal.attachBehaviors();

Solution
Add a 'processed' class and filtering before assigning an event handler.

In file features.js
Replace

$('#features-export-wrapper input[type=checkbox]', context).click(function() {

with

$('#features-export-wrapper input[type=checkbox]:not(.processed)', context).addClass('processed').click(function() {

Patch to follow

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alex.skrypnyk’s picture

Issue summary: View changes
alex.skrypnyk’s picture

mpotter’s picture

Status: Active » Needs work

But what happens when you try to uncheck the box to move it back to it's original selection? Seems like this would prevent any further action of the checkbox.

Also, I cannot reproduce the original issue. Do you maybe have some other module that is causing this behavior?

alex.skrypnyk’s picture

.click() is binding an event to an element and the fix in the patch prevents creation and binding multiple instances of click event handlers. So, it will still bind a click() event handler, but only once.

Any module can call Drupal.attachBehaviors() and any existing behavior should expect this and should be idempotent to such call.

To reproduce the issue, call Drupal.attachBehaviors() odd number of times after features UI page is loaded (even from the chrome console).

mpotter’s picture

Status: Needs work » Needs review

Ahh, right you are. Sorry I didn't read that code correctly. Definitely only want to bind this once.

mpotter’s picture

Status: Needs review » Fixed

Committed to 21213ad.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.