Skip to content

fix(hierarchicalGrid): Ensure col instances created from ri cols are … - #17507

Open
MayaKirova wants to merge 1 commit into
22.0.xfrom
mkirova/fix-17502-22.0.x
Open

fix(hierarchicalGrid): Ensure col instances created from ri cols are …#17507
MayaKirova wants to merge 1 commit into
22.0.xfrom
mkirova/fix-17502-22.0.x

Conversation

@MayaKirova

Copy link
Copy Markdown
Contributor

…destroyed.

Closes #17502

Description

Destroy column instances that are created for child grids from row island column declarations, since they seem to remain after target grid is destroyed for some reason.

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

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

Fixes a memory-leak scenario in the Hierarchical Grid by explicitly tracking and destroying dynamically created column component instances that originate from IgxRowIslandComponent declarative column definitions.

Changes:

  • Track ComponentRefs created when materializing row-island columns for child grids.
  • Destroy tracked column ComponentRefs during ngOnDestroy of the grid instance to prevent detached elements from remaining in memory.
Suppressed comments (2)

projects/igniteui-angular/grids/hierarchical-grid/src/hierarchical-grid-base.directive.ts:226

  • This change fixes a memory-leak scenario by explicitly destroying dynamically-created column component refs on grid destroy, but there are no unit tests to prevent regressions. Consider adding a spec that creates a hierarchical grid with row-island declarative columns, expands a row (creating child grid columns), destroys the grid, and asserts the created ComponentRefs are destroyed / no longer retained.
    public override ngOnDestroy() {
        this.destroyRowIslandColumnRefs();
        super.ngOnDestroy();
    }

projects/igniteui-angular/grids/hierarchical-grid/src/hierarchical-grid-base.directive.ts:147

  • createColumnsList() can be invoked multiple times for the same child grid (e.g. when row-island columns change). Currently it only appends new ComponentRefs into _rowIslandColumnRefs and doesn’t clean up previously created refs, so memory can grow until the grid is destroyed. Consider destroying the existing row-island column refs at the start of createColumnsList() before creating the new set.
        topLevelCols.forEach((col) => {
            col.grid = this;
            const ref = this._createColumn(col);
            this._rowIslandColumnRefs.push(ref);

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

/* blazorSuppress */
public abstract expandChildren: boolean;

protected _rowIslandColumnRefs: ComponentRef<IgxColumnComponent>[] = [];
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.

3 participants