Skip to content

fix(for-of): call recalcUpdateSizes via afterNextRender in zoneless mode#17325

Open
viktorkombov wants to merge 3 commits into
masterfrom
vkombov/fix-17280
Open

fix(for-of): call recalcUpdateSizes via afterNextRender in zoneless mode#17325
viktorkombov wants to merge 3 commits into
masterfrom
vkombov/fix-17280

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 virtual scroll size cache updates in Angular zoneless change detection by scheduling recalcUpdateSizes() via afterNextRender when NgZone is NoopNgZone, preventing clipped last rows after scrolling (MRL grids regression).

Changes:

  • Updated IgxForOfDirective/IgxGridForOfDirective scroll handlers to call recalcUpdateSizes() via afterNextRender(...read...) in zoneless mode, while preserving the existing zone.onStable path in zone-based mode.
  • Updated IgxGridBaseDirective resize notification handling to skip zone.run() in zoneless mode.
  • Added a unit test to verify recalcUpdateSizes is invoked after vertical scroll under provideZonelessChangeDetection().

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-triggered work while still notifying changes.
projects/igniteui-angular/directives/src/directives/for-of/for_of.directive.ts Adds zoneless-aware scheduling of recalcUpdateSizes() via afterNextRender in multiple scroll handlers.
projects/igniteui-angular/directives/src/directives/for-of/for_of.directive.spec.ts Adds a zoneless unit test ensuring recalcUpdateSizes() runs 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

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 2 comments.

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.

igxGrid - The last row is not fully displayed.

2 participants