Problem/Motivation

When you use ctrl+shift to select multiple rows in a multi-page table view the selection is not reflected in the "Selected X items in this view". Also the seelction is not properly taken to the next page.

You can test this by following the steps:

  • Create a multi-paged view of type table (see attachment for example) and views bulk operation field (e.g. with block and unblock user actions)
  • Go to this view, use shift to select multiple items, e.g. 3
  • The fieldset on the page says "Selected 2 items in this view" while you expect 3.
  • When you do the action it executes it on 3 items.

Another scenario:

  • Select 3 users again using the shift method
  • Go to the next page, select 1 more user.
  • See that the fieldset says "Selected 3 items in this view" while you expect 4.
  • When you do the action it executes on 3 items.

Proposed resolution

Ideally this should work as this module uses the core library drupal.tableselect which supports this as well. When using shift to select multiple items this should be reflected in the fieldset on the page, but also while doing the action.

Comments

jaapjan created an issue. See original summary.

renrhaf’s picture

We also encountered this bug

graber’s picture

I tried pressing ctrl-shift on a VBO view and on a core bulk operations view, both with tableselect.. nothing happened.
I tried using tab and space to make selection - worked on both.

Can you tell me more about this selection method? I'm using a Mac and Chrome..

renrhaf’s picture

Hi Graber, usually to select multiple entries in a tableselect, I check the first one I want to be selected, then I scroll to the last item I want selected and keep shift pressed while clicking in the checkbox. All rows between the first and last one are selected.
It seems that VBO does only consider first and last as checked. I'm on Windows and Firefox/Chrome.

graber’s picture

Issue tags: +JavaScript

You're right.. I have no idea how to handle this at the moment, just that it has to be done in js/frontUi.js some similar way the tableselect select all checkbox is handled.

graber’s picture

What's with the ctrl in description then when you need to hold shift only?

renrhaf’s picture

I'm not sure about the ctrl mentioned in the description, but I think it's related to the same underlying issue.
Maybe @jaapjan could enlight this matter ?

renrhaf’s picture

Status: Active » Needs review
StatusFileSize
new7.24 KB
new7.26 KB

Here is a patch for using same behavior as the tableSelect.
I also created a patch for the current 8.x-3.13 version of the module.

renrhaf’s picture

StatusFileSize
new7.15 KB
new7.17 KB

Fixing an issue with "Select / deselect all results in this view (all pages, ... total)" checkbox

n_e_’s picture

This patch also fixes issues with multi-selection for the 4.x branch.

graber’s picture

Version: 8.x-2.4 » 4.1.x-dev

Bumping version for this.

renrhaf’s picture

StatusFileSize
new7.2 KB

Rerolled patch for 4.1 branch

renrhaf’s picture

Version: 4.1.x-dev » 4.2.x-dev
StatusFileSize
new7.15 KB

Rerolled patch for 4.2 branch.
Can someone test this patch so we can RTBC ?
Or else I'm doomed to do rerolls for eternity ;)

Status: Needs review » Needs work

The last submitted patch, 13: multiselect-shift-3019720-13.patch, failed testing. View results

graber’s picture

Yes, yes, I was afraid of this as the last JS improvement broke things and had to fix myself as of course the commit author didn't treat that as a priority. Luckily we have JS tests on now.

I'll commit this when I see it's sufficiently tested, don't want additional hotfixing after the next release.

renrhaf’s picture

Okay thanks, sorry I did not mean to put the rush on you. Thank you for all your work on this module.
I will help as much as possible, tell me if anything has to be changed on this patch.
I see the tests failed, I'll take a look on it

graber’s picture

I know JS tests can be tricky so a few hints:

  • https://github.com/graber-1/ddev-drupal - working ddev stack where you just install VBO and can run phpunit and FunctionalJavascript will work out of the box.
  • Use Drupal\FunctionalJavascriptTests\WebDriverTestBase::createScreenshot() ($this->createScreenshot()), wherever needed - it helps a lot.
graber’s picture

Issue tags: -JavaScript +JavaScript

I think I came up with a more simple solution, described it there. In short we don't have to check what key the user pressed but just check state of all checkboxes in the view. It should be a very small change this way.

kopeboy’s picture

StatusFileSize
new35.47 KB

Actually I just found out that after updating Drupal core from 10.0.9 to 10.1.0 even a normal click selection (not just in a table display but unformatted list as well) is not reflected in the vbo form wrapper (which is now at the bottom of the view only).

After checking one or more items, the buttons are enabled (and vbo will correctly execute on them) but "No items selected" is not updated.
vbo no items selected

Should I open another issue or should this be solved here?

kopeboy’s picture

StatusFileSize
new29.26 KB

When using core's "Bulk update" views field instead of "Views bulk operations", the selection is updated in the UI instead:
core action items selected

kopeboy’s picture

This comment in the related issue might be relevant and the cause of my bug:

graber’s picture

Status: Needs work » Needs review
StatusFileSize
new8.79 KB

Please test this one, it's using my last concept.

The good thing about it is that it should be fool proof in all cases, every change checks the entire page state.
The bad thing is a bit worse performance as we send more data and do more checking in the frontend but it shouldn't be an issue.

Also contains a bit of cleanup.

Please test in the following areas as there may be regressions:
- multiple VBO views on the same page
- multiple tables (was it aggregation?)

solideogloria’s picture

#22 does fix the shift+click issue, and the selection logic is much better than before.

However, I noticed that the VBO count part that says "Selected # items" doesn't update properly after clicking a "select all" checkbox. I have a view with rows grouped by a field, so there are multiple "select all" checkboxes, one for each grouping. Still, I think I could reproduce this with only a single "select all".

Example with 5 rows:

  1. Click a checkbox on a row (selected 1 item)
  2. Click the "select all" checkbox (selected 1 item, WRONG: should be 5)
  3. Click a checkbox on a row to deselect (selected 4 items)
  4. Click the same to select it again (selected 5 items)
  5. Click the "select all" checkbox (none selected, VBO is hidden)
  6. Click the "select all" checkbox (selected 0 items, WRONG: should be 5)

Note that each time I say to click "select all", I'm talking about the select all checkbox on the table, not the "Select / deselect all results (all pages, # total)" shown by the VBO popup.

graber’s picture

StatusFileSize
new10.63 KB

Thank you for your testing @solideogloria, I fixed the mentioned issue, please retest, hopefully now all is ok.

graber’s picture

Assigned: Unassigned » graber
Status: Needs review » Needs work
graber’s picture

Assigned: graber » Unassigned
Status: Needs work » Needs review
StatusFileSize
new13.42 KB

This should do the trick. Please retest.

solideogloria’s picture

Status: Needs review » Reviewed & tested by the community

Patch #26 fixes the issues I mentioned in #23.

  • Graber committed 92754f07 on 4.2.x
    Issue #3019720 by Renrhaf, Graber, jaapjan: Selection not properly...
graber’s picture

Status: Reviewed & tested by the community » Fixed

Thank you.

shane birley’s picture

I just tested the patch as well. I can confirm it works! Thanks, @Graber.

Status: Fixed » Closed (fixed)

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