listbox and richlistbox should potentially keep selectedItems sorted




8 years ago
8 years ago


(Reporter: hobophobe, Unassigned)


Firefox Tracking Flags

(Not tracked)




8 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20100729 Iceweasel/3.6.7 (like Firefox/3.6.7)
Build Identifier: 

listbox (and by extension richlistbox) currently keep the selectedItems array in the order items were selected.  Worse, it seems that richlistbox can _refreshSelection() which will reorder them as they appear in the listing.

Instead, they should be kept in the order they appear in the listing (eg, rebuild if the listing is sorted, etc.).

Reproducible: Always

Steps to Reproduce:
1. Select items in a (rich)listbox using Cmd+click or via keyboard in a random order.
2. Iterate over the selectedItems and print the indexes.
Actual Results:  
The indexes are printed in the order their items were added to the selection.

Expected Results:  
The indexes are printed in the order they appear in the listing.

I'm not aware if anything depends on the current behavior, or whether it was intended.  There are at least some cases where the consumer will want the items in sorted order, though.  bug 626484, where the Web Console copies selected items is an example of that use case.

Workaround is that the consumer can sort the items to achieve the desired result.
You need to log in before you can comment on or make changes to this bug.