Selection not properly updated on multi-page view when using Ctrl+Shift

Created on 11 December 2018, almost 6 years ago
Updated 29 July 2023, over 1 year ago

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.

🐛 Bug report
Status

Fixed

Version

4.2

Component

User interface

Created by

🇳🇱Netherlands jaapjan

Live updates comments and jobs are added and updated live.
  • JavaScript

    Affects the content, performance, or handling of Javascript.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇵🇱Poland Graber

    I think I came up with a more simple solution, described it there 🐛 The UI selection logic doesn't work correctly Needs review . 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.

  • 🇮🇹Italy kopeboy Milan

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

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

  • 🇮🇹Italy kopeboy Milan

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

  • 🇮🇹Italy kopeboy Milan

    This comment 🐛 The UI selection logic doesn't work correctly Needs review in the related issue might be relevant and the cause of my bug:

  • Status changed to Needs review over 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update over 1 year ago
    14 pass
  • 🇵🇱Poland Graber

    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.

  • #22 does fix the shift+click issue.

    However, I noticed that the VBO 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 one shown by the VBO popup.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update over 1 year ago
    14 pass
  • 🇵🇱Poland Graber

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

  • Assigned to Graber
  • Status changed to Needs work over 1 year ago
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update over 1 year ago
    14 pass
  • 🇵🇱Poland Graber

    This should do the trick. Please retest.

  • Status changed to RTBC over 1 year ago
  • 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...
  • Status changed to Fixed over 1 year ago
  • 🇵🇱Poland Graber

    Thank you.

  • 🇨🇦Canada Shane Birley

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

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

Production build 0.71.5 2024