Skip to content

Commit

Permalink
Only clean parent when it is current box, otherwise iot has already b…
Browse files Browse the repository at this point in the history
…een set
  • Loading branch information
joswarmer committed Oct 14, 2024
1 parent 8ef58ce commit 7e14904
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/core/src/editor/boxes/LayoutBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export abstract class LayoutBox extends Box {
}

replaceChildren(children: Box[]): LayoutBox {
this._children.forEach((ch) => (ch.parent = null));
this._children.forEach((ch) => { if(ch.parent === this) ch.parent = null });
// this._children.forEach((ch) => ch.parent = null);
this._children.splice(0, this._children.length);
if (!!children) {
children.forEach((child) => {
Expand All @@ -60,6 +61,8 @@ export abstract class LayoutBox extends Box {

clearChildren(): void {
const dirty = this._children.length !== 0;
this._children.forEach((ch) => { if(ch.parent === this) ch.parent = null });
// this._children.forEach((ch) => ch.parent = null);
this._children.splice(0, this._children.length);
if (dirty) {
LOGGER.log("Layout clearChildren dirty " + this.role);
Expand Down Expand Up @@ -131,7 +134,7 @@ export abstract class LayoutBox extends Box {
export class HorizontalLayoutBox extends LayoutBox {
kind: string = "HorizontalLayoutBox";

constructor(element: FreNode, role: string, children?: (Box | null)[], initializer?: Partial<HorizontalLayoutBox>) {
constructor(element: FreNode, role: string, children?: Box[], initializer?: Partial<HorizontalLayoutBox>) {
super(element, role, children, initializer);
this.direction = ListDirection.HORIZONTAL;
}
Expand All @@ -140,7 +143,7 @@ export class HorizontalLayoutBox extends LayoutBox {
export class VerticalLayoutBox extends LayoutBox {
kind: string = "VerticalLayoutBox";

constructor(element: FreNode, role: string, children?: Box[], initializer?: Partial<HorizontalLayoutBox>) {
constructor(element: FreNode, role: string, children?: Box[], initializer?: Partial<VerticalLayoutBox>) {
super(element, role, children, initializer);
this.direction = ListDirection.VERTICAL;
}
Expand Down

0 comments on commit 7e14904

Please sign in to comment.