Skip to content

Commit b935b91

Browse files
committed
setComponentIndex bugfix
1 parent eb8d910 commit b935b91

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

haxe/ui/backend/ComponentImpl.hx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,16 @@ class ComponentImpl extends ComponentBase {
351351
}
352352

353353
private override function handleSetComponentIndex(child:Component, index:Int) {
354-
if (index == cast(this, Component).childComponents.length - 1) {
354+
if (index == this.childComponents.length - 1) {
355355
element.appendChild(child.element);
356356
} else {
357-
HtmlUtils.insertBefore(cast(this, Component).childComponents[index + 1].element, child.element);
357+
if (index == this.childComponents.indexOf(child) - 1) {
358+
var before = this.childComponents[index];
359+
HtmlUtils.insertBefore(before.element, child.element);
360+
} else {
361+
var before = this.childComponents[index + 1];
362+
HtmlUtils.insertBefore(before.element, child.element);
363+
}
358364
}
359365
}
360366

0 commit comments

Comments
 (0)