In flex, I'm using a component which displays a specific item (selectedItem field) from its dataProvider (ListCollectionView).
The elements of my dataProvider can be edited by different means. Each time one is edited, an update event is sent, leading to update the dataProvider collection (ListCollectionView::listChangeHandler).
In the process, if my selectedItem is the edited element, it is erased (set to null via the ListCollectionView::moveItemInView), even if the edited field is used nowhere.
Is there a way to avoid this ?
More specifically without having to save it before, having it lost and restoring it afterwards (which would be hardly practicable here)
Edit : Okay, I think I can explain further :
In my code, I make an affectation on a property of one of the items of the list which is databinded to the dataProvider. I don't know exactly why, probably because the class of the item is [bindable], this throws an update event.
This event is caught by the ArrayList::itemUpdateHandler which dispatches it to the ListCollectionView::listChangeHandler. At this point, the event "kind" is "update", which seems ok to me…
But from there, it goes to ListCollectionView::moveItemInView (I suppose that it makes sens as the item should have to update its position if the list is sorted). This function removes the item from it's former location and added it to its new location.
As it removes it, it sends a new Event with "remove" kind. And this is where the thing goes wrong : my component listens the remove events of the data it uses and removes its selectedItem if this element is removed.
I think it is around the call to moveItemInView that there is a problem : the call in ListCollectionView::handlePropertyChangeEvents (called by listChangeHandler) is : moveItemInView(updateEntry.item, updateEntry.item, eventItems); (where updateEntry.item is the modified item of the list and eventItems an empty array)
Whereas its prototype is : private function moveItemInView(item:Object, dispatch:Boolean = true, updateEventItems:Array = null):void
Is that a bug ?