fix(grids): getState no longer mutates live sorting/groupBy/filtering expressions#17198
Merged
fix(grids): getState no longer mutates live sorting/groupBy/filtering expressions#17198
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a grid state regression where calling getState() mutated the grid’s live sorting/groupBy/filtering expression objects (e.g., deleting strategy/owner), which could break later re-application of those expressions.
Changes:
- Clone sorting and grouping expressions before stripping non-serializable props (
strategy/owner) so live expressions are not mutated. - Clone filtering/advancedFiltering expression trees (recursively) while stripping
owner, avoiding in-place mutation of the live tree. - Add unit tests asserting
getState()does not mutate live sorting/groupBy/filtering/advancedFiltering expressions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
projects/igniteui-angular/src/lib/grids/state.directive.spec.ts |
Adds regression tests for non-mutating getState() behavior (but currently focuses the suite). |
projects/igniteui-angular/src/lib/grids/state-base.directive.ts |
Updates getFeatureState implementations to return cloned state instead of mutating live expressions; adds a recursive filtering tree clone helper. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the grid state directive where calling getState() mutated the grid’s live sorting/grouping/filtering expressions (e.g., deleting strategy / owner), which could break later usage of those expressions (as reported in #17105).
Changes:
- Update
getStatefeature extractors for sorting and groupBy to return sanitized copies (instead of mutating the live expressions). - Update filtering and advanced filtering state extraction to clone the filtering tree while stripping
owner, avoiding mutation of the live tree. - Add unit tests asserting
getStatedoes not mutate live sorting, grouping, filtering, and advanced filtering expressions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| projects/igniteui-angular/src/lib/grids/state-base.directive.ts | Avoids in-place deletion of strategy/owner by copying expressions; introduces recursive filtering-tree cloning that strips owner. |
| projects/igniteui-angular/src/lib/grids/state.directive.spec.ts | Adds regression tests covering non-mutation of live sorting/groupBy/filtering/advancedFiltering expressions when calling getState. |
ChronosSF
approved these changes
Apr 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #17105
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)