Skip to content

fix(query-builder): refactor expression tree change emission for consistency - master#17081

Open
IMinchev64 wants to merge 2 commits intomasterfrom
iminchev/qb-treechange-circular-fix
Open

fix(query-builder): refactor expression tree change emission for consistency - master#17081
IMinchev64 wants to merge 2 commits intomasterfrom
iminchev/qb-treechange-circular-fix

Conversation

@IMinchev64
Copy link
Contributor

Closes #https://github.com/Infragistics-Developer-Tools/dev-tools/issues/3208

Additional information (check all that apply):

  • Bug fix
  • New functionality
  • Documentation
  • Demos
  • CI/CD

Checklist:

  • All relevant tags have been applied to this PR
  • This PR includes unit tests covering all the new code (test guidelines)
  • This PR includes API docs for newly added methods/properties (api docs guidelines)
  • This PR includes feature/README.MD updates for the feature docs
  • This PR includes general feature table updates in the root README.MD
  • This PR includes CHANGELOG.MD updates for newly added functionality
  • This PR contains breaking changes
  • This PR includes ng update migrations for the breaking changes (migrations guidelines)
  • This PR includes behavioral changes and the feature specification has been updated with them

@IMinchev64 IMinchev64 added the ❌ status: awaiting-test PRs awaiting manual verification label Mar 23, 2026
Copilot AI review requested due to automatic review settings March 23, 2026 14:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors Query Builder expression tree change emission to be more consistent by emitting a sanitized/serializable expression tree and by centralizing internal tree-change emits.

Changes:

  • Added JSON-based cloning/sanitization of the expression tree before emitting expressionTreeChange from IgxQueryBuilderComponent.
  • Refactored IgxQueryBuilderTreeComponent to emit tree changes via a helper method.
  • Updated tree comparison logic to ignore the externalObject property.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
projects/igniteui-angular/query-builder/src/query-builder/query-builder.component.ts Emits a sanitized/serialized clone of the expression tree on change.
projects/igniteui-angular/query-builder/src/query-builder/query-builder-tree.component.ts Centralizes internal change emission and ignores externalObject during init comparison.

if (key === 'externalObject') {
return undefined;
}

Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

getSerializableExpressionTree uses JSON.stringify with a replacer that only strips externalObject. However, query-builder expressions can store searchVal as a Set (e.g. for in conditions), and JSON.stringify(new Set([...])) serializes to {}, losing the selected values. This will corrupt the emitted tree. Consider extending the replacer to convert Set values (at least for key === 'searchVal') to an array, similar to the existing grid/state serialization callbacks in the repo.

Suggested change
if (key === 'searchVal' && val instanceof Set) {
// Ensure Set-based search values (e.g. for "in" conditions) are serialized correctly
// JSON.stringify(new Set([...])) => '{}' by default, so convert to an array first
return Array.from(val);
}

Copilot uses AI. Check for mistakes.
Comment on lines +330 to +335
private serializeExpressionTreeCallback(key: string, val: any) {
if (key === 'externalObject') {
return undefined;
}

return val;
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

The new serializeExpressionTreeCallback introduces an any-typed parameter. To keep typings strict (and consistent with the rest of this file), consider using unknown (or the built-in JSON.stringify replacer signature types) and adding an explicit return type for the callback.

Copilot uses AI. Check for mistakes.
Comment on lines 352 to 354
if (this._shouldEmitTreeChange) {
this.expressionTreeChange.emit(tree);
this.expressionTreeChange.emit(this.getSerializableExpressionTree(this._expressionTree));
}
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

This change alters the payload of expressionTreeChange by emitting a JSON-serialized clone of the tree (and filtering out externalObject). There are existing unit tests for Query Builder interactions, but none assert the emitted tree contents. Please add coverage that verifies (1) externalObject is not present in the emitted payload, and (2) searchVal for Set-based conditions is preserved (e.g. serialized as an array and can be round-tripped back via recreateTree).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants