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

Command icon 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

sgjohnston created an issue. See original summary.

sgjohnston’s picture

Additional: 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).

sriram s made their first commit to this issue’s fork.

sriram_s’s picture

Status: Active » Needs review

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

graber made their first commit to this issue’s fork.

  • graber committed 2265ebd8 on 4.4.x authored by sriram s
    Issue #3593915 by sgjohnston, sriram s: Guard the multipage selector...
graber’s picture

Status: Needs review » Fixed

Looks good, thanks

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.