Skip to content

fix(grids): getState no longer mutates live sorting/groupBy/filtering expressions#17198

Merged
ChronosSF merged 2 commits into20.1.xfrom
vkombov/fix-17105-20.1.x
Apr 20, 2026
Merged

fix(grids): getState no longer mutates live sorting/groupBy/filtering expressions#17198
ChronosSF merged 2 commits into20.1.xfrom
vkombov/fix-17105-20.1.x

Conversation

@viktorkombov
Copy link
Copy Markdown
Contributor

Closes #17105

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

Copilot AI review requested due to automatic review settings April 16, 2026 14:09
Copy link
Copy Markdown
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

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.

Comment thread projects/igniteui-angular/src/lib/grids/state.directive.spec.ts Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
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

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 getState feature 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 getState does 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.

@viktorkombov viktorkombov requested a review from ChronosSF April 17, 2026 06:42
@ChronosSF ChronosSF added ✅ status: verified Applies to PRs that have passed manual verification and removed ❌ status: awaiting-test PRs awaiting manual verification labels Apr 20, 2026
@ChronosSF ChronosSF merged commit b867b35 into 20.1.x Apr 20, 2026
9 of 10 checks passed
@ChronosSF ChronosSF deleted the vkombov/fix-17105-20.1.x branch April 20, 2026 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

grid: state-persistence version: 20.1.x ✅ status: verified Applies to PRs that have passed manual verification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants