Uploaded image for project: 'Apache Flex'
  1. Apache Flex
  2. FLEX-27749

Spark List control does not assign the selectedIndices vectors in the correct order when ctrl-clicking several contiguous or discontiguous items.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • Adobe Flex SDK 4.5.1 (Release)
    • None
    • Spark: List
    • None
    • Affected OS(s): Windows
      Affected OS(s): Windows
      Browser: Other (specify version)
      Language Found: English

    Description

      I have a Spark List with a tile layout that is populated with thumbnail images. I have allowMultipleSelection set to true so that I can select a number of the thumbnails to delete. I don't have a problem deleting the files if I shift-select a bunch of contiguous files, but if I ctrl-click multiple files, especially discontiguous files, the wrong files get deleted. Let me rephrase, the files get deleted in the wrong order, and using an arrayCollection as the dataProvider, if you delete the wrong file first without knowing about it, all subsequent deletions will be pointing at the wrong index. The selected items are stored in a group of vectors that are supposed to hold the indices in the reverse order than they were selected. Here is the documentation from the Flex 4.5 Help:

      "These Vectors contain a list of the selected indices and selected data items in the reverse order in which they were selected. That means the first element in each Vector corresponds to the last item selected."

      Upon tracing the indices in my application, I found that they were not in the reverse order than they were selected. So I looked at the example underneath of the documentation Adobe provides and you can see the problem for yourself. The problem is perfectly demonstrated in the sample program that they provide. Here is the link:

      Steps to reproduce:

      1. Go to the following link and Scroll about halfway down the screen to the section entitled "Handling multiple selection in the Spark List control" and run the sample application under that heading.

      http://help.adobe.com/en_US/flex/using/WSc2368ca491e3ff923c946c5112135c8ee9e-7fff.html

      2. If you click the first item and then shift-click the fourth item, the selected indices show 3-2-1-0 which is correct. But if you select the first item(index 0), ctrl-click the third item(index 2) and the fifth item(index 4), the selected indices list should show 4-2-0 but it doesn't, it shows 4-0-2. Continue ctrl-clicking and it gets more erratic in its listing. According to the documentation, it should be in the reverse order to what was selected, but it is not. This is what is happening in my application as well. A trace of the indices is not the reverse order from what I select. When deleting items from an arrayCollection for the dataprovider, this can cause a lot of problems if you don't know what order they are being deleted.

      Actual Results: When allowMultipleSelection is set to true in a Spark List, the selectedIndices property does not populate the vectors in the correct order when ctrl-clicking multiple List items, which according to Adobe documentation, the vectors should be in the reverse order from which they were selected. (it works if you shift-click multiple items)

      Expected Results: When allowMultipleSelection is set to true in a spark list, the selectedIndices property should populate the index vectors in the reverse order from which they were selected when ctrl-clicking multiple items.(it works if you shift-click multiple items)

      Workaround (if any): I have not thought of a workaround for the order in which non-contiguous items are selected. But if you are deleting items from an array collection, you need to deleted items from the top down. If you delete an early indice first, then all the later indices will no longer be pointing at the correct pieces of data because the arrayCollection will change. So you could do a sort of the vectors to put them in order of highest to lowest or lowest to highest or whatever your particular needs are. But I do not know how you would be able to determine what order they were selected.

      Attachments

        Activity

          People

            Unassigned Unassigned
            adobejira Adobe JIRA
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: