Skip to content

Commit

Permalink
Merge pull request #626 from Shallowmallow/BoxItemRenderers
Browse files Browse the repository at this point in the history
Try to remove only direct item renderer children
  • Loading branch information
ianharrigan authored Aug 29, 2024
2 parents 9075091 + ffe5e78 commit 33973d0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions haxe/ui/containers/Box.hx
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,11 @@ private class Builder extends CompositeBuilder {
_box.itemRenderer.handleVisibility(false);
}

var childRenderers = _component.findComponents(ItemRenderer, 1);

for (i in 0...dataSource.size) {
var item = dataSource.get(i);
var renderer = findRenderer(item);
var renderer = findRenderer(item, childRenderers);
if (renderer == null) {
renderer = itemRenderer.cloneComponent();
_box.addComponent(renderer);
Expand All @@ -155,7 +157,7 @@ private class Builder extends CompositeBuilder {
renderer.data = item;
}

for (child in _component.findComponents(ItemRenderer)) {
for (child in childRenderers) {
if (child == _box.itemRenderer) {
continue;
}
Expand All @@ -165,8 +167,8 @@ private class Builder extends CompositeBuilder {
}
}

private function findRenderer(data:Dynamic):ItemRenderer {
for (child in _component.findComponents(ItemRenderer)) {
private function findRenderer(data:Dynamic, renderers:Array<ItemRenderer>):ItemRenderer {
for (child in renderers) {
if (child.data == data) {
return child;
}
Expand Down

0 comments on commit 33973d0

Please sign in to comment.