Skip to content

Commit 5966d67

Browse files
committed
properly handle child switch in SingleChildWidget
1 parent 5fd7aa6 commit 5966d67

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/main/java/com/cleanroommc/modularui/widget/SingleChildWidget.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ public W child(IWidget child) {
2929
if (child == this || this.child == child) {
3030
return getThis();
3131
}
32-
32+
if (this.child != null) {
33+
this.child.dispose();
34+
}
3335
this.child = child;
34-
if (isValid()) {
36+
updateList();
37+
if (child != null && isValid()) {
3538
child.initialise(this, true);
39+
scheduleResize();
3640
}
37-
updateList();
3841
return getThis();
3942
}
4043
}

0 commit comments

Comments
 (0)