Thursday, October 6, 2011

ListCollectionViewCursor and 0-length lists

There's an ugly bug in ListCollectionView's cursor class (ListCollectionViewCursor). To see it, do the following:
  1. Start with a List whose dataProvider is a ListCollectionView around the array [ "a", "b", "c", "d", "e", "f" ].
  2. Click "c" in the list.  yourList.selectedItem is now "c"
  3. Do something that filters "c" out of the dataProvider but keeps at least 1 item.  yourList.selectedItem is now null
  4. Reset the filter
  5. Click "c" again.  yourList.selectedItem is now "c"
  6. Do something that filters the dataProvider down to 0 length
  7. yourList.selectedItem is still "c"

#3 is the correct behavior - you should not be allowed to have selectedItem be something that's not included in the dataProvider. #6 is a bug.