Skip to content

feat(ag-grid-angular-theme): added row (row group) state and store directives (#DS-5046) - #195

Merged
artembelik merged 2 commits into
mainfrom
feat/DS-5046
Jul 20, 2026
Merged

feat(ag-grid-angular-theme): added row (row group) state and store directives (#DS-5046)#195
artembelik merged 2 commits into
mainfrom
feat/DS-5046

Conversation

@artembelik

@artembelik artembelik commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added persistence for grid row selection and focused-cell state across page reloads.
    • Supports saving state in browser storage or URL query parameters.
    • Added restoration and reset controls for row groups, selections, and focus.
    • Exposed the new grid state features through the Angular theme module.
  • Tests

    • Added comprehensive automated coverage for persistence, restoration, reset behavior, and asynchronous state storage.

@artembelik artembelik self-assigned this Jul 20, 2026
Copilot AI review requested due to automatic review settings July 20, 2026 11:52
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: cf934df5-3845-4298-a6f5-2360ed1f9fba

📥 Commits

Reviewing files that changed from the base of the PR and between fe213eb and 1915407.

📒 Files selected for processing (4)
  • packages/ag-grid-angular-theme/src/row-group.ng.ts
  • packages/ag-grid-angular-theme/src/row-selection-state.ng.ts
  • packages/ag-grid-angular-theme/tests/row-group.ng.spec.ts
  • packages/ag-grid-angular-theme/tests/row-selection-state.ng.spec.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/ag-grid-angular-theme/tests/row-selection-state.ng.spec.ts
  • packages/ag-grid-angular-theme/tests/row-group.ng.spec.ts
  • packages/ag-grid-angular-theme/src/row-selection-state.ng.ts
  • packages/ag-grid-angular-theme/src/row-group.ng.ts

📝 Walkthrough

Walkthrough

Adds persistent row selection, row focus, and row-group state using local storage or URL query parameters. The changes include Angular directives, public exports, development routes and pages, reset controls, unit tests, and Playwright coverage.

Changes

AG Grid state persistence

Layer / File(s) Summary
Row selection persistence
packages/ag-grid-angular-theme/src/row-selection-state.ng.ts, packages/ag-grid-angular-theme/tests/row-selection-state.ng.spec.ts, dev/ag-grid-angular/src/tests/row-selection-state.*
Adds configurable local-storage and query-parameter stores, selection restoration and reset behavior, Angular components, and automated tests.
Row focus persistence
packages/ag-grid-angular-theme/src/row-focus-state.ng.ts, packages/ag-grid-angular-theme/tests/row-focus-state.ng.spec.ts, dev/ag-grid-angular/src/tests/row-focus-state.*
Adds focused-cell persistence stores and directive handling, with development components and unit and browser tests.
Row-group state persistence
packages/ag-grid-angular-theme/src/row-group.ng.ts, packages/ag-grid-angular-theme/tests/row-group.ng.spec.ts, dev/ag-grid-angular/src/tests/row-group.*
Persists collapsed group paths and selected row IDs, restores delayed row data, adds reset behavior, and validates local-storage and async store flows.
Public exports and development routes
packages/ag-grid-angular-theme/index.ts, packages/ag-grid-angular-theme/src/module.ng.ts, dev/ag-grid-angular/src/main.ts
Exports the new directives, includes them in the Angular module, and registers lazy-loaded development routes.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Grid as ag-grid-angular
  participant State as State directive
  participant Store as LocalStorage or query-param store
  User->>Grid: Select row or focus cell
  Grid->>State: Emit selectionChanged or cellFocused
  State->>Store: Persist state
  User->>Grid: Reload page
  Grid->>State: Emit firstDataRendered
  State->>Store: Read persisted state
  Store-->>State: Return row or focus state
  State->>Grid: Restore selection or focused cell
Loading

Suggested reviewers: lskramarov, nikgurev

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is clear and related to the change, though it only mentions row group state and omits the new row selection and row focus directives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/DS-5046

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit 1915407):

https://data-grid-next--data-grid-pr-195-qrdwj7r8.web.app

(expires Thu, 23 Jul 2026 12:15:30 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: b9d49913f5b5988e9af8690a8b37f16143707448

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 expands @koobiq/ag-grid-angular-theme with new persistence directives (row selection + focused cell) and adds persistence options to KbqAgGridRowGroup (collapsed group paths + group-aware selection), with accompanying unit + Playwright coverage and dev demo routes.

Changes:

  • Added KbqAgGridRowSelectionState and KbqAgGridRowFocusState directives with LocalStorage and query-param store implementations.
  • Extended KbqAgGridRowGroup with persisted collapsed/expanded state and persisted group-aware row selection state.
  • Added Jest specs + Playwright E2E scenarios and dev demo pages/routes for the new features.

Reviewed changes

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

Show a summary per file
File Description
packages/ag-grid-angular-theme/tests/row-selection-state.ng.spec.ts Unit tests for the new row-selection persistence directive.
packages/ag-grid-angular-theme/tests/row-focus-state.ng.spec.ts Unit tests for the new focused-cell persistence directive.
packages/ag-grid-angular-theme/tests/row-group.ng.spec.ts Added unit tests for row-group collapsed/selection persistence behaviors.
packages/ag-grid-angular-theme/src/row-selection-state.ng.ts New directive + stores for persisting/restoring AG Grid row selection.
packages/ag-grid-angular-theme/src/row-focus-state.ng.ts New directive + stores for persisting/restoring AG Grid focused cell.
packages/ag-grid-angular-theme/src/row-group.ng.ts Added collapsed-path and selection persistence (stores, inputs, restore/save wiring).
packages/ag-grid-angular-theme/src/module.ng.ts Exported the new directives via the theme module.
packages/ag-grid-angular-theme/index.ts Exported the new directives/stores from the public API.
dev/ag-grid-angular/src/tests/row-selection-state.playwright-spec.ts E2E coverage for row-selection persistence (localStorage + query params).
dev/ag-grid-angular/src/tests/row-selection-state.ng.ts Dev demo components for row-selection persistence.
dev/ag-grid-angular/src/tests/row-focus-state.playwright-spec.ts E2E coverage for focused-cell persistence (localStorage + query params).
dev/ag-grid-angular/src/tests/row-focus-state.ng.ts Dev demo components for focused-cell persistence.
dev/ag-grid-angular/src/tests/row-group.ts Dev row-group demo updated to wire collapsed + selection persistence and reset UI.
dev/ag-grid-angular/src/tests/row-group.playwright-spec.ts E2E coverage for row-group collapsed + selection persistence.
dev/ag-grid-angular/src/main.ts Added dev routes for the new persistence demos.

Comment thread packages/ag-grid-angular-theme/src/row-group.ng.ts
Comment thread packages/ag-grid-angular-theme/src/row-selection-state.ng.ts Outdated
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Note

Unit test generation is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
dev/ag-grid-angular/src/tests/row-selection-state.ng.ts (1)

59-66: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Template-bound members should be protected in both dev components. As per coding guidelines: "Use protected for template bindings."

  • dev/ag-grid-angular/src/tests/row-selection-state.ng.ts#L59-L66: change store, stateKey, columnDefs, rowSelection, getRowId, rowData to protected.
  • dev/ag-grid-angular/src/tests/row-focus-state.ng.ts#L57-L64: change store, stateKey, columnDefs, defaultColDef, getRowId, rowData to protected.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@dev/ag-grid-angular/src/tests/row-selection-state.ng.ts` around lines 59 -
66, Change the template-bound members in DevRowSelectionState to protected:
rowData, store, stateKey, columnDefs, rowSelection, and getRowId. Apply the same
visibility change in DevRowFocusState for rowData, store, stateKey, columnDefs,
defaultColDef, and getRowId; no other behavior changes are needed.

Source: Coding guidelines

packages/ag-grid-angular-theme/src/row-selection-state.ng.ts (1)

20-21: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Route window access through an injectable token (addresses the existing KBQ_WINDOW TODOs). All four stores read window.localStorage / window.location directly, which is not resolvable under SSR/non-browser rendering and hinders testability. Injecting a KBQ_WINDOW-style token (as the TODOs note) fixes this uniformly. I can open an issue or draft the token wiring if helpful.

  • packages/ag-grid-angular-theme/src/row-selection-state.ng.ts#L20-L21: replace window.localStorage with the injected window token.
  • packages/ag-grid-angular-theme/src/row-selection-state.ng.ts#L56-L57: replace window.location with the injected window token.
  • packages/ag-grid-angular-theme/src/row-focus-state.ng.ts#L26-L27: replace window.localStorage with the injected window token.
  • packages/ag-grid-angular-theme/src/row-focus-state.ng.ts#L62-L63: replace window.location with the injected window token.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/ag-grid-angular-theme/src/row-selection-state.ng.ts` around lines 20
- 21, Replace direct browser window access with an injectable KBQ_WINDOW-style
token across the affected stores: update row-selection-state.ng.ts lines 20-21
and 56-57, and row-focus-state.ng.ts lines 26-27 and 62-63, injecting and
reusing the token for localStorage and location access while preserving existing
store behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@dev/ag-grid-angular/src/tests/row-focus-state.ng.ts`:
- Line 76: Update the animateRows binding in the affected row-focus state test
to use Angular property binding with [animateRows]="false" instead of the
literal string attribute, matching the existing DevRowFocusState fix.
- Line 40: Update the animateRows usage in the row-focus test fixture to
property-bind the boolean value with [animateRows]="false", ensuring animations
are actually disabled instead of passing the truthy string "false".

In `@dev/ag-grid-angular/src/tests/row-selection-state.ng.ts`:
- Line 78: Update the animateRows binding in the row-selection state test to use
Angular property binding with a boolean false value instead of the string
literal, matching the expected behavior in DevRowSelectionState.

---

Nitpick comments:
In `@dev/ag-grid-angular/src/tests/row-selection-state.ng.ts`:
- Around line 59-66: Change the template-bound members in DevRowSelectionState
to protected: rowData, store, stateKey, columnDefs, rowSelection, and getRowId.
Apply the same visibility change in DevRowFocusState for rowData, store,
stateKey, columnDefs, defaultColDef, and getRowId; no other behavior changes are
needed.

In `@packages/ag-grid-angular-theme/src/row-selection-state.ng.ts`:
- Around line 20-21: Replace direct browser window access with an injectable
KBQ_WINDOW-style token across the affected stores: update
row-selection-state.ng.ts lines 20-21 and 56-57, and row-focus-state.ng.ts lines
26-27 and 62-63, injecting and reusing the token for localStorage and location
access while preserving existing store behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8a0c4d90-b797-4f69-b1b4-f2ab90effaac

📥 Commits

Reviewing files that changed from the base of the PR and between b20575c and fe213eb.

📒 Files selected for processing (15)
  • dev/ag-grid-angular/src/main.ts
  • dev/ag-grid-angular/src/tests/row-focus-state.ng.ts
  • dev/ag-grid-angular/src/tests/row-focus-state.playwright-spec.ts
  • dev/ag-grid-angular/src/tests/row-group.playwright-spec.ts
  • dev/ag-grid-angular/src/tests/row-group.ts
  • dev/ag-grid-angular/src/tests/row-selection-state.ng.ts
  • dev/ag-grid-angular/src/tests/row-selection-state.playwright-spec.ts
  • packages/ag-grid-angular-theme/index.ts
  • packages/ag-grid-angular-theme/src/module.ng.ts
  • packages/ag-grid-angular-theme/src/row-focus-state.ng.ts
  • packages/ag-grid-angular-theme/src/row-group.ng.ts
  • packages/ag-grid-angular-theme/src/row-selection-state.ng.ts
  • packages/ag-grid-angular-theme/tests/row-focus-state.ng.spec.ts
  • packages/ag-grid-angular-theme/tests/row-group.ng.spec.ts
  • packages/ag-grid-angular-theme/tests/row-selection-state.ng.spec.ts

Comment thread dev/ag-grid-angular/src/tests/row-focus-state.ng.ts
Comment thread dev/ag-grid-angular/src/tests/row-focus-state.ng.ts
Comment thread dev/ag-grid-angular/src/tests/row-selection-state.ng.ts
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

✅ Created PR with unit tests: #196

@artembelik
artembelik merged commit 3c6a1bb into main Jul 20, 2026
8 checks passed
@artembelik
artembelik deleted the feat/DS-5046 branch July 20, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants