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.
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
Comment | File | Size | Author |
---|---|---|---|
#2 | 2499369-Unable-to-select-component-checkbox-stays-unchecked-1.patch | 481 bytes | alex.skrypnyk |
Comments
Comment #1
alex.skrypnykComment #2
alex.skrypnykPatch attached
Comment #3
mpotter CreditAttribution: mpotter commentedBut 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?
Comment #4
alex.skrypnyk.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).
Comment #5
mpotter CreditAttribution: mpotter commentedAhh, right you are. Sorry I didn't read that code correctly. Definitely only want to bind this once.
Comment #7
mpotter CreditAttribution: mpotter commentedCommitted to 21213ad.