Problem/Motivation
When selecting an entry from a table, VBO crashes with:
TypeError: undefined is not an object (evaluating '$summary[0].textContent=Drupal.formatPlural(data.count,'Selected 1 item','Selected @count items')')
from line 4173 in
success(data) {
selectionObject.totalCount = data.count;
$selectionInfo.html(data.selection_info);
$summary[0].textContent = Drupal.formatPlural(data.count, 'Selected 1 item', 'Selected @count items');
selectionObject.toggleButtonsState();
selectionObject.ajaxing = false;
}
I think the issue is $summary is not an array.
This code is updating the number of selected items, and because of the fault the remainder of the code does not execute, including enabling the Apply button.
Setting 'Show an "Items selected" details element' to 'Always hide' stops the issue, presumably because the selected count is not updated.
Unfortunately I don't know when this was introduced - we are using v4.4.5, but the view hasn't been used for some time, so it could have been introduced in a previous version.
Steps to reproduce
Using a table view and VBO, select a row in the table, or select all. The Apply button is not enabled, and the error is seen in the console.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork views_bulk_operations-3593915
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
sgjohnston commentedAdditional: this will I think only happen if there are enough rows in the table to cause the number of selected items to be displayed (eg 'Show an "Items selected" details element' is set to Always show, or Default and the number of table entries mean the results are paged).
Comment #5
sriram_s commentedRan into this one myself while working with a table view and VBO, clicked a row and the whole selection just froze, Apply stuck disabled, TypeError in the console. Turned out to be $summary[0] being undefined: when the details widget renders without a native summary element, .find('summary') comes back empty, so assigning .textContent to nothing throws and kills the rest of the callback, which is why the count never updates. Your note about it showing up with paged / "Always show" results lines up exactly with when I hit it, sgjohnston.
MR !165 (against 4.4.x) just guards that line so it's skipped when there's no summary, and left alone otherwise. Didn't add a test here, since reproducing it means pulling the summary out of the DOM by hand, which the standard test themes never do on their own. Can add one if you'd prefer.
Comment #8
graber commentedLooks good, thanks