Skip to content

fix(hierarchical-grid): align selected data with expanded row indexes - master#17299

Open
georgianastasov wants to merge 4 commits into
masterfrom
ganastasov/fix-17295-master
Open

fix(hierarchical-grid): align selected data with expanded row indexes - master#17299
georgianastasov wants to merge 4 commits into
masterfrom
ganastasov/fix-17295-master

Conversation

@georgianastasov
Copy link
Copy Markdown
Contributor

Closes #17295

Description

This PR fixes a Hierarchical Grid issue where copying/selecting a cell from an expanded parent row returned the value from the previous row.

The fix uses dataView as the selected data source and keeps child-grid placeholder rows as null to preserve index alignment with visible rows.

Motivation / Context

After expanding the Artist Ahmad Nazeri row, copying its Artist cell returned Artist Babila Ebwélé instead of the selected row value.

This happened because selection indexes were based on visible rows, while the selected data source did not account for expanded child-grid placeholder rows.

Type of Change (check all that apply):

  • Bug fix
  • New functionality
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring (no functional changes)
  • Documentation
  • Demos
  • CI/CD
  • Tests
  • Changelog
  • Skills/Agents

Component(s) / Area(s) Affected:

Hierarchical Grid, cell selection/copy

How Has This Been Tested?

Added a regression test that expands the Artist Ahmad Nazeri row, selects its Artist cell, and verifies getSelectedData() returns the correct value instead of the previous row value.|

  • Unit tests
  • Manual testing
  • Automated e2e tests

Test Configuration:

  • Angular version: 22.0.x
  • Browser(s): All
  • OS: All

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
  • Accessibility (ARIA, keyboard navigation, focus management) has been verified

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 Hierarchical Grid bug (#17295) where copying/selecting a cell on an expanded parent row returned the value of the previous row. The root cause was that getSelectedData() used filteredSortedData as the source while cell-selection indexes are based on visible rows (which include expanded child-grid placeholder rows). The fix overrides getSelectedData() in the hierarchical grid to use dataView with null placeholders for child-grid records, keeping index alignment, and narrows the existing index-subtraction branch in extractDataFromSelection so it no longer double-corrects.

Changes:

  • Override getSelectedData() in IgxHierarchicalGridComponent to build a source from dataView with null for child-grid placeholder rows.
  • Restrict the hierarchical-specific row-index adjustment in extractDataFromSelection to only apply when the source is filteredSortedData.
  • Add a regression unit test reproducing the original copy-from-expanded-row scenario.

Reviewed changes

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

File Description
projects/igniteui-angular/grids/hierarchical-grid/src/hierarchical-grid.component.ts Adds getSelectedData override that pads dataView with null placeholders for child-grid records.
projects/igniteui-angular/grids/grid/src/grid-base.directive.ts Gates the hierarchical row-index subtraction logic so it only runs when the source is filteredSortedData.
projects/igniteui-angular/grids/hierarchical-grid/src/hierarchical-grid.integration.spec.ts Adds regression test verifying selected data on an expanded parent row returns the correct value.

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.

HierarchicalGrid copies value from previous row after row is expanded

2 participants