Skip to content

Improve Grid Stability With Angular Zoneless Change Detection #17364

Description

@viktorkombov

Component / Area

Grid

Is your feature request related to a problem?

Angular v21+ uses zoneless change detection by default. Angular v20
applications can also opt in explicitly, and tests can reproduce this runtime
with provideZonelessChangeDetection().

Some Grid paths relied on NgZone.onStable as a scheduling point after layout,
scroll, virtualization, or auto-sizing work. Angular's zoneless guide states
that NgZone.onStable does not emit in zoneless applications, so these paths
need a real update, render, or DOM boundary instead of depending on zone
lifecycle notifications.

The goal is to keep the existing zone-based behavior stable while making the
confirmed Grid scenarios reliable in zoneless applications.

Describe the solution you'd like

Resolve the confirmed Grid zoneless issues in this branch with targeted
production changes and regression coverage.

  • Use provideZonelessChangeDetection() in consumer-style tests.
  • Avoid post-action fixture.detectChanges() in tests that verify zoneless
    runtime behavior.
  • Assert public behavior such as rendered rows, emitted events, measured
    auto-size values, or public Grid state.
  • Keep zone-based applications on the existing scheduling path where that path
    already worked.
  • Use direct change detection, render callbacks, browser callbacks, or public
    Grid notifications only when they match the work being performed.

Proposed API or Usage

No public API change is expected.

The branch only changes internal scheduling for confirmed Grid paths that were
blocked by NgZone.onStable in zoneless mode.

Example test setup:

TestBed.configureTestingModule({
    imports: [TestHostComponent],
    providers: [provideZonelessChangeDetection()]
});

Describe alternatives you've considered

  • Replacing every NgZone.onStable usage globally. This is too broad and risks
    changing behavior that is still valid in zone-based applications.
  • Triggering change detection everywhere after async work. This can hide
    missing notifications and does not follow Angular's zoneless guidance.
  • Keeping all zoneless tests in one bucket. A focused flat-grid zoneless spec is
    useful for cross-cutting runtime coverage, while Pivot Grid behavior belongs
    in the existing Pivot Grid spec because it is component-specific.

How important is this feature to you?

Important. Zoneless change detection is the default in Angular v21+, so
confirmed Grid scenarios should not depend on zone lifecycle scheduling.

Additional context

This task is intentionally limited to the issues resolved by the current
branch. Broader Tree Grid, Hierarchical Grid, directive-level, or editing-flow
investigations should be logged separately if they need follow-up work.

Angular zoneless guide:
https://angular.dev/guide/zoneless

Resolved in this branch

  • Flat Grid async sorting renders after fixture.whenStable() without an
    additional fixture.detectChanges().
  • Flat Grid async filtering and clearing filters render after
    fixture.whenStable() without an additional fixture.detectChanges().
  • Flat Grid filteringDone emits for filter() and clearFilter() in a
    zoneless test environment.
  • Flat Grid horizontal column virtualization emits parentVirtDir.chunkLoad
    and observes shifted virtualized column state in zoneless mode.
  • Flat Grid fit-content column auto-sizing re-measures after explicit
    recalculation and header data changes.
  • Flat Grid recycled virtual row state restore no longer depends on
    NgZone.onStable in zoneless mode.
  • Pivot Grid row dimension auto-sizing is covered in its existing spec and
    does not require manual change detection after grid sizing.
  • Existing zone-based scheduling behavior is preserved for the changed
    paths.

Test organization

  • Flat Grid zoneless regressions are covered in
    projects/igniteui-angular/grids/grid/src/grid.zoneless.spec.ts because they
    validate cross-cutting runtime behavior in an explicitly zoneless TestBed.
  • Pivot Grid dimension auto-sizing is covered in
    projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.spec.ts because
    it is component-specific behavior.

Suggested validation

  • npm run test:lib:grid
  • npm run test:lib:pgrid
  • npm run lint:lib

Metadata

Metadata

Assignees

Fields

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions