On Tue, Dec 30, 2008 at 7:52 PM, Sergey Kovalyov
<skovalyov.flexcod...@gmail.com> wrote:

[comments inline]

> Steps to reproduce:
>
> Create an application with the Tree component instance and XMLListCollection
> dataProvider binded to it that contains 5 items:
>
> private var itemsXML : XML =
>  <items>
>   <item name="Item 1" isBranch="true" />
>   <item name="Item 2" isBranch="true" />
>   <item name="Item 3" isBranch="true" />
>   <item name="Item 4" isBranch="true" />
>   <item name="Item 5" isBranch="true" />
>  </items>;
>
> Expand Item 4.
> Drag and drop Item 5 from the root to the Item 4.
> Drag and drop Item 5 from the Item 4 to the root.
>
>
> Expected result: Item 5 is deleted from the Item 4 and appears on the root
> in the drop position.
>
> Actual result: Item 5 actually appears on the root in the drop position, but
> it is not removed from the Item 4, so there are 2 same elements in the
> hierarchy intead of one.

That's a good catch. You're right, it's because of parentMap not
getting updated on the first drag-drop. You'll see that the
HierarchicalCollectionView:collecitonChangeHandler has a call to
updateLength when the event kind is "update", but it has been
commented. I suspect that may be the reason for this bug. Anyhow, for
now, here's a workaround:

 <Tree ... dragDrop="callLater(doWorkaround)" ... />

 function doWorkaround() {
   var e = new CollectionEvent("collectionChange");
   e.kind = "update";
   myXMLListCollection.dispatchEvent(e);
 }

See if that works.

This ought to be logged in the Flex bugbase.

Manish

Reply via email to