igniteui-angular 21.2.8 → 21.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4559,11 +4559,15 @@ class IgxForOfDirective extends IgxForOfToken {
4559
4559
  const container = this.dc.instance._vcr;
4560
4560
  for (let i = start; i < end && this.igxForOf[i] !== undefined; i++) {
4561
4561
  const embView = this._embeddedViews.shift();
4562
- if (!embView.destroyed) {
4562
+ if (embView && !embView.destroyed) {
4563
4563
  this.scrollFocus(embView.rootNodes.find(node => node.nodeType === Node.ELEMENT_NODE)
4564
4564
  || embView.rootNodes[0].nextElementSibling);
4565
4565
  const view = container.detach(0);
4566
+ // embView and view both refer to the same collections
4566
4567
  this.updateTemplateContext(embView.context, i);
4568
+ // Because in Elements the whole parent div (containing data-index) gets removed (possibly due to being disconnected). In Angular it just gets moved.
4569
+ // This ensures to update it with the new context and remove it first from DOM because of detach action before inserting it manually.
4570
+ view.detectChanges();
4567
4571
  container.insert(view);
4568
4572
  this._embeddedViews.push(embView);
4569
4573
  }
@@ -4577,11 +4581,13 @@ class IgxForOfDirective extends IgxForOfToken {
4577
4581
  const container = this.dc.instance._vcr;
4578
4582
  for (let i = prevIndex - 1; i >= this.state.startIndex && this.igxForOf[i] !== undefined; i--) {
4579
4583
  const embView = this._embeddedViews.pop();
4580
- if (!embView.destroyed) {
4584
+ if (embView && !embView.destroyed) {
4581
4585
  this.scrollFocus(embView.rootNodes.find(node => node.nodeType === Node.ELEMENT_NODE)
4582
4586
  || embView.rootNodes[0].nextElementSibling);
4587
+ // embView and view both refer to the same collections
4583
4588
  const view = container.detach(container.length - 1);
4584
4589
  this.updateTemplateContext(embView.context, i);
4590
+ view.detectChanges();
4585
4591
  container.insert(view, 0);
4586
4592
  this._embeddedViews.unshift(embView);
4587
4593
  }