Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1719,7 +1719,7 @@ export class IgxQueryBuilderTreeComponent implements AfterViewInit, OnDestroy {
this.cancelOperandEdit();

// Ignore values of certain properties for the comparison
const propsToIgnore = ['parent', 'hovered', 'ignoreCase', 'inEditMode', 'inAddMode'];
const propsToIgnore = ['parent', 'hovered', 'ignoreCase', 'inEditMode', 'inAddMode', 'externalObject'];
const propsReplacer = function replacer(key, value) {
if (propsToIgnore.indexOf(key) >= 0) {
return undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,14 +327,30 @@ export class IgxQueryBuilderComponent implements OnDestroy {
this.queryTree.setAddButtonFocus();
}

private stripExternalObject(tree: IExpressionTree): void {
for (const operand of tree?.filteringOperands ?? []) {
if ('operator' in operand) {
this.stripExternalObject(operand);
continue;
}

Comment thread
IMinchev64 marked this conversation as resolved.
delete (operand.condition as any)?.externalObject;

if (operand.searchTree) {
this.stripExternalObject(operand.searchTree);
}
}
}

protected onExpressionTreeChange(tree: IExpressionTree) {
if (tree && this.entities && tree !== this._expressionTree) {
this._expressionTree = recreateTree(tree, this.entities);
} else {
this._expressionTree = tree;
}
if (this._shouldEmitTreeChange) {
this.expressionTreeChange.emit(tree);
this.stripExternalObject(this._expressionTree);
this.expressionTreeChange.emit(this._expressionTree);
}
Comment thread
IMinchev64 marked this conversation as resolved.
}

Expand Down Expand Up @@ -389,4 +405,3 @@ export class IgxQueryBuilderComponent implements OnDestroy {
});
}
}

10 changes: 9 additions & 1 deletion src/app/query-builder/query-builder.sample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,15 @@ export class QueryBuilderComponent implements OnInit {
// this.expressionTree = tree;
// this.onChange();
}
return tree ? JSON.stringify(tree, null, 2) : 'Please add an expression!';
return tree ? JSON.stringify(tree, this.serializeExpressionTreeCallback, 2) : 'Please add an expression!';
}

// JSON.stringify serializes Set as {}, so convert Set-based searchVal to array to preserve values in the printed output.
private serializeExpressionTreeCallback(key: string, val: any) {
if (key === 'searchVal' && val instanceof Set) {
return Array.from(val);
}
return val;
}
Comment on lines +198 to 203
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In serializeExpressionTreeCallback, consider avoiding any (e.g. use unknown) and making the replacer a readonly arrow function property. That keeps typing stricter and avoids accidental future reliance on a class-method this context when passing it to JSON.stringify.

Suggested change
private serializeExpressionTreeCallback(key: string, val: any) {
if (key === 'searchVal' && val instanceof Set) {
return Array.from(val);
}
return val;
}
private readonly serializeExpressionTreeCallback = (key: string, val: unknown) => {
if (key === 'searchVal' && val instanceof Set) {
return Array.from(val);
}
return val;
};

Copilot uses AI. Check for mistakes.

public canCommitExpressionTree() {
Expand Down
Loading