Can select multiple files in downloads view when only one expected

Bug #1534112 reported by Olivier Tilloy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical System Image
Fix Committed
Undecided
Unassigned
ubuntu-ui-toolkit (Ubuntu)
Invalid
Medium
Unassigned
webbrowser-app (Ubuntu)
Fix Released
Medium
Olivier Tilloy

Bug Description

(originally reported in bug #1528651)

Steps to reproduce:

 1) Browse to http://www.wufoo.com/html5/attributes/07-accept.html, click the "Select file" button
 2) Choose the browser as a content source
 3) Tap the first download in the list to select it
 4) Tap the second download in the list to select it, the first download is unselected
 5) Tap the first download again, the second one is unselected
 6) Tap the second one again

Expected result: the first download in the list is unselected, only the second one is selected.

Current result: both the first and the second download are selected.

Related branches

Olivier Tilloy (osomon)
description: updated
Revision history for this message
Olivier Tilloy (osomon) wrote :

I can reproduce the problem outside of the browser app, with the following standalone QML example:

import QtQuick 2.4
import Ubuntu.Components 1.3

ListView {
  id: listview
  width: 300
  height: 120
  model: 2
  delegate: ListItem {
    selectMode: true
    Label {
      anchors.centerIn: parent
      text: "selected: " + selected
    }
    property bool lastSelected: false
    onSelectedChanged: {
      if (selected && !lastSelected) {
        listview.ViewItems.selectedIndices = [index]
      }
      lastSelected = selected
    }
  }
}

To reproduce, check the first item, then the second one, then the first one again, then the second one again.

Revision history for this message
Andrea Bernabei (faenil) wrote :

I confirm the bug as of ubuntu-ui-toolkit r1908

Changed in ubuntu-ui-toolkit (Ubuntu):
assignee: nobody → Zsombor Egri (zsombi)
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Olivier Tilloy (osomon) wrote :

So it appears it’s not a bug in the UITK, but in the way it is being used in the browser and in the standalone example (see comment #1). Changing ViewItems.selectedIndices in onSelectedChanged is not a good idea.

I came up with a different approach which solves that issue:

import QtQuick 2.4
import Ubuntu.Components 1.3

ListView {
  id: listview
  width: 300
  height: 120
  model: 2
  delegate: ListItem {
    ListItemLayout {
      title.text: "selected: " + selected
    }
  }
  property int selectedIndex: -1
  ViewItems.selectMode: true
  ViewItems.onSelectedIndicesChanged: {
    if (ViewItems.selectedIndices.length > 1 && selectedIndex != -1) {
      var selection = ViewItems.selectedIndices
      selection.splice(selection.indexOf(selectedIndex), 1)
      selectedIndex = selection[0]
      ViewItems.selectedIndices = selection
      return
    }
    if (ViewItems.selectedIndices.length > 0) {
      selectedIndex = ViewItems.selectedIndices[0]
    } else {
      selectedIndex = -1
    }
  }
}

However I’m now seeing another issue: after selecting the first item, then the second one, then the first one again, the 'selected' property of the item doesn’t reflect the current state: the first item is selected, selectedIndices is [0], yet the first delegate’s selected property is false.

Changed in ubuntu-ui-toolkit (Ubuntu):
assignee: Zsombor Egri (zsombi) → nobody
status: Confirmed → Invalid
Olivier Tilloy (osomon)
Changed in webbrowser-app (Ubuntu):
assignee: nobody → Olivier Tilloy (osomon)
status: Triaged → In Progress
importance: High → Medium
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package webbrowser-app - 0.23+16.04.20160408.1-0ubuntu1

---------------
webbrowser-app (0.23+16.04.20160408.1-0ubuntu1) xenial; urgency=medium

  [ CI Train Bot ]
  * Resync trunk.

  [ Loïc Molinari ]
  * Made AddressBar height scalable with regards to the grid units
    system.

  [ Olivier Tilloy ]
  * Add dep8 tests and instructions to run them in qemu or on a phone.
    Original work by Leo Arias and Vincent Ladeuil. added: debian/tests/
    debian/tests/control debian/tests/touch-session-autopilot
  * Catch ESC key event one level up to ensure that it’s not incorrectly
    bubbled up to the outer component. (LP: #1557016)
  * Customize the contents of the media permission dialog to avoid
    truncated text. (LP: #1554220)
  * Do not write the session to a temporary file when no target file is
    defined.
  * Fix a failing unit test with Qt 5.6. (LP: #1565507)
  * Fix broken webapp container autopilot tests. (LP: #1557019)
  * Fix issues with item selection in the downloads page: do not allow
    selecting multiple files when only one is expected do not allow
    entering delete mode (with a long press on an item) while in picker
    mode (LP: #1534112, #1561575)
  * Fix unit tests when run under an sbuild chroot. (LP: #1567294)
  * Import QQuickShortcut from Qt 5.5 to properly handle window-level
    keyboard shortcuts. We cannot bump the dependency on Qt to 5.5 as
    the stable overlay PPA for devices currently has Qt 5.4.1. (LP:
    #1542224, #1545802, #1537782)
  * Make the autopilot tests more reliable when dragging the bottom
    edge. (LP: #1560109)
  * Remove workaround for bug #1526940 that was fixed in the latest
    release of the UITK. (LP: #1526940)
  * Rename debian packages to follow new QML module naming convention.
    (LP: #1342031)
  * Simplify the implementation of HistoryViewWide quite a bit, and as a
    side effect fix a unit test failure when run against the staging
    branch of the UITK. (LP: #1567337)

 -- Olivier Tilloy <email address hidden> Fri, 08 Apr 2016 17:07:04 +0000

Changed in webbrowser-app (Ubuntu):
status: In Progress → Fix Released
Olivier Tilloy (osomon)
Changed in canonical-devices-system-image:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.