Skip to content

fix(for-of): call recalcUpdateSizes via afterNextRender in zoneless mode - 21.2.x#17326

Open
viktorkombov wants to merge 3 commits into
21.2.xfrom
vkombov/fix-17280-21.2.x
Open

fix(for-of): call recalcUpdateSizes via afterNextRender in zoneless mode - 21.2.x#17326
viktorkombov wants to merge 3 commits into
21.2.xfrom
vkombov/fix-17280-21.2.x

Conversation

@viktorkombov

Copy link
Copy Markdown
Contributor

Closes #17280

Description

In zoneless Angular (provideZonelessChangeDetection), NoopNgZone.onStable never emits, so recalcUpdateSizes() was never called after scrolling. This left the virtual scroll size cache uncorrected, causing the last visible row in MRL grids to appear partially clipped.

Motivation / Context

In for_of.directive.ts, at all three scroll handler sites, detect zoneless mode and use afterNextRender({ read: () => recalcUpdateSizes() }) instead of zone.onStable.pipe(first()).subscribe(recalcUpdateSizes). Zone mode keeps the original path unchanged (replacing it unconditionally breaks an existing zone-based scroll test).
In grid-base.directive.ts, the resizeNotify handler skips zone.run() in zoneless mode - notifyChanges() already calls markForCheck() which schedules CD via the zoneless scheduler.

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:

Grid, For-of

How Has This Been Tested?

Added a zoneless describe block in for_of.directive.spec.ts verifying recalcUpdateSizes is called after scroll when using provideZonelessChangeDetection.

  • Unit tests
  • Manual testing
  • Automated e2e tests

Test Configuration:

  • Angular version:
  • Browser(s):
  • OS:

Screenshots / Recordings

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 virtualization sizing regression when running Ignite UI grids under zoneless Angular change detection, where NgZone.onStable never fires and the virtual size cache is left stale after scrolling (leading to clipped last visible rows).

Changes:

  • Update IgxForOfDirective scroll handlers to detect zoneless mode and schedule recalcUpdateSizes() via afterNextRender(...) instead of NgZone.onStable.
  • Update IgxGridBaseDirective resize notification handling to avoid zone.run(...) in zoneless mode.
  • Add a unit test covering zoneless scrolling behavior to ensure recalcUpdateSizes() is invoked.

Reviewed changes

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

File Description
projects/igniteui-angular/grids/grid/src/grid-base.directive.ts Avoids zone.run() in zoneless mode for resize notifications while keeping zone-based behavior unchanged.
projects/igniteui-angular/directives/src/directives/for-of/for_of.directive.ts Ensures recalcUpdateSizes() is scheduled after render in zoneless mode across relevant scroll handlers.
projects/igniteui-angular/directives/src/directives/for-of/for_of.directive.spec.ts Adds zoneless test coverage validating recalcUpdateSizes() is called after vertical scroll.

Comment thread projects/igniteui-angular/directives/src/directives/for-of/for_of.directive.ts Outdated
Comment thread projects/igniteui-angular/directives/src/directives/for-of/for_of.directive.ts Outdated
Comment thread projects/igniteui-angular/directives/src/directives/for-of/for_of.directive.ts Outdated

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

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.

2 participants