Possible bug with datasource ( ListView component)

I found two problems with ListView when I have a custom itemrender :

  1. Adding one row of data calls the onDataChanged(…) 5-7 times

Example:

       var listView = new ListView();
        listView.percentWidth = 100;
        listView.percentHeight = 100;
        listView.itemRenderer =  new MyTestItemRender();
        var gameRoomList = new ArrayDataSource<Dynamic>();
        listView.dataSource = gameRoomList;
        gameRoomList.add({ myName : "One", count : 3});
        Screen.instance.addComponent(listView);

class MyTestItemRender extends ItemRenderer
{
    public function new() {
        super();
    }

   private override function onDataChanged(data:Dynamic) 
   {
            super.onDataChanged(data);
            if (data != null) {
                trace("Call onDataChanged");
            }
    }
}
  1. Removing a row from the datasource ( with listView.dataSource.removeAt(i) ) lead to wrong interpretation of the components in the next row wich replaced the removed one.
    It’s a bit more complicated to give an example here because the bug from 1), but it goes something like this:
 class MyTestItemRender extends ItemRenderer
{

   var myHBox:HBox;
 
   public function new() {
       super();
       myHBox = new HBox();
       this.addComponent(myHBox );
   }
   private override function onDataChanged(data:Dynamic) 
   {
       super.onDataChanged(data);
       if (data != null) {
          // check some criteria and add different count of image components
          .......
          var myImage:Image = new Image();
          var myImage.....
          var myImage....
          .... //set image resource
          myHBox.addComponent(myImage);
          myHBox.addComponent(myImageTwo);
          myHBox.addComponent(.....);
       }
   }

where I add three rows in the list view

gameRoomList.add({ myName : "One", count : 3});
gameRoomList.add({ myName : "Two", count : 4});
gameRoomList.add({ myName : "Three", count : 2});

Let’s say I have a button and when I click it I will call listView.dataSource.removeAt(2)
The second row will disapear , but it will keep the count of components of that missing row ( example 4 ) and not the correct one 2 ( from the third row)
It’s a little bit hard to exaplin it , but if you want I can try to create more comple example.

Im not sure im following: http://haxeui.org/builder/?soxkkz

@ianharrigan Here is the test project where the two problems are visible: https://drive.google.com/file/d/1_wHKkOEyFtWbdLgxFtgsnjXvZjBKNsKz/view?usp=sharing

After load the project you can do :

  1. The first test with calling onDataChanged() more than once. Just click on ‘Test 1 - Add’ button and check the console.
    You will see:
src/lv/MyListItemRenderer.hx:32: Call OnDataChanged , Count = 1
src/lv/MyListItemRenderer.hx:32: Call OnDataChanged , Count = 2
src/lv/MyListItemRenderer.hx:32: Call OnDataChanged , Count = 3

for only one action roomList.add({ myName : "One", count : -1});

  1. Reload the project. Click on 'Test 2 - Remove ( Step 1 ) ’ button this will load 4 rows with images.
    Click on 'Test 2 - Remove ( Step 2 ) ’ . This will remove the third row. As you can see the third row name is replaced with the text Four , but the images are still from the row three not four. This is the second bug.

P.S. Something strange happend as I load only 4 , 3 , 2 and 1 image per row , but there is more images. Maybe it’s not other bug.