fix(query-builder): refactor expression tree change emission for consistency - master#17081
fix(query-builder): refactor expression tree change emission for consistency - master#17081IMinchev64 wants to merge 7 commits intomasterfrom
Conversation
There was a problem hiding this comment.
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
expressionTreeChangefromIgxQueryBuilderComponent. - Refactored
IgxQueryBuilderTreeComponentto emit tree changes via a helper method. - Updated tree comparison logic to ignore the
externalObjectproperty.
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. |
projects/igniteui-angular/query-builder/src/query-builder/query-builder.component.ts
Show resolved
Hide resolved
projects/igniteui-angular/query-builder/src/query-builder/query-builder.component.ts
Outdated
Show resolved
Hide resolved
projects/igniteui-angular/query-builder/src/query-builder/query-builder.component.ts
Show resolved
Hide resolved
…com/IgniteUI/igniteui-angular into iminchev/qb-treechange-circular-fix
| } | ||
|
|
||
| private emitExpressionTreeChange(): void { | ||
| this.expressionTreeChange.emit(this._expressionTree); |
There was a problem hiding this comment.
What is the purpose of this going into a separate method?
| return tree; | ||
| } | ||
|
|
||
| return JSON.parse(JSON.stringify(tree, this.serializeExpressionTreeCallback)); |
There was a problem hiding this comment.
This is introducing a behavior change. Let's say that any of the filtering operands is having custom logic as condition. The condition contains logic function that would be lost in the JSON.stringify. So if we bind to the expressionTreeChange of the query builder and change the grids expressionTree in the handler an error is thrown:
| return tree; | ||
| } | ||
|
|
||
| return JSON.parse(JSON.stringify(tree, this.serializeExpressionTreeCallback)); |
There was a problem hiding this comment.
I have not tested this but what would happen if there are dates as searchValue. They might work correct because we do a lot of date parsing but .stringify would parse them to ISO string. Could you confirm that this works as well?
Closes #https://github.com/Infragistics-Developer-Tools/dev-tools/issues/3208
Additional information (check all that apply):
Checklist:
feature/README.MDupdates for the feature docsREADME.MDCHANGELOG.MDupdates for newly added functionalityng updatemigrations for the breaking changes (migrations guidelines)