Skip to content

fix(elements): Ensure ForOF out of bound row gets deleted before moving to opposite side.#17334

Merged
dkamburov merged 2 commits into
masterfrom
dkamburov/fix-for-of-elements
Jun 18, 2026
Merged

fix(elements): Ensure ForOF out of bound row gets deleted before moving to opposite side.#17334
dkamburov merged 2 commits into
masterfrom
dkamburov/fix-for-of-elements

Conversation

@dkamburov

@dkamburov dkamburov commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Closes #17179

Description

Motivation / Context

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:

How Has This Been Tested?

  • 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

This PR targets a virtualization issue affecting Elements scenarios (reported in #17179), where view recycling/disconnection can lead to incorrect DOM/state updates and, in turn, incorrect scroll sizing/behavior. It also adjusts a grid grouping virtualization test to better stabilize/assert horizontal virtualization state after vertical scrolling.

Changes:

  • Updates IgxForOfDirective view-reuse logic to guard against missing embedded views and to force a view detectChanges() before reinsertion (Elements-specific behavior).
  • Tweaks an IgxGrid GroupBy spec to restore virtualization state after vertical scrolling and reduce timing-related flakiness.

Reviewed changes

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

File Description
projects/igniteui-angular/directives/src/directives/for-of/for_of.directive.ts Adjusts recycled view handling during scroll-based view rearrangement (Elements/disconnection scenario).
projects/igniteui-angular/grids/grid/src/grid.groupby.spec.ts Updates a virtualization regression test to stabilize state restoration after scroll.

Comment on lines 1063 to 1068
for (let i = start; i < end && this.igxForOf[i] !== undefined; i++) {
const embView = this._embeddedViews.shift();
if (!embView.destroyed) {
if (embView && !embView.destroyed) {
this.scrollFocus(embView.rootNodes.find(node => node.nodeType === Node.ELEMENT_NODE)
|| embView.rootNodes[0].nextElementSibling);
const view = container.detach(0);
Comment on lines 1088 to 1095
for (let i = prevIndex - 1; i >= this.state.startIndex && this.igxForOf[i] !== undefined; i--) {
const embView = this._embeddedViews.pop();
if (!embView.destroyed) {
if (embView && !embView.destroyed) {
this.scrollFocus(embView.rootNodes.find(node => node.nodeType === Node.ELEMENT_NODE)
|| embView.rootNodes[0].nextElementSibling);
// embView and view both refer to the same collections
const view = container.detach(container.length - 1);

Comment on lines +2666 to 2676
await wait(100); // Triggers onStable
fix.detectChanges();

dataRows = grid.dataRowList.toArray();
// Workaround for await wait triggering onStable prematurely
(grid as any)._restoreVirtState(dataRows[7]);
await wait(100);
fix.detectChanges();

// verify rows are scrolled to the right
dataRows = grid.dataRowList.toArray();
dataRows.forEach(dr => {
Comment on lines +1072 to 1076
// Because in Elements the whole parent div (containing data-index) gets removed (possibly due to being disconnected). In Angular it just gets moved.
// This ensures to update it with the new context and remove it first from DOM because of detach action before inserting it manually.
view.detectChanges();

container.insert(view);
@dkamburov dkamburov changed the title Dkamburov/fix for of elements fix(elements): Ensure ForOF out of bound row gets deleted before moving to opposite side. Jun 18, 2026
@dkamburov dkamburov merged commit 9fb27ce into master Jun 18, 2026
7 checks passed
@dkamburov dkamburov deleted the dkamburov/fix-for-of-elements branch June 18, 2026 09:10
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.

Adding Paginator/Toolbar to Row Island of a Hierarchical Grid breaks vertical scrollbar when expanding children

3 participants