-
Notifications
You must be signed in to change notification settings - Fork 160
fix(elements): Ensure ForOF out of bound row gets deleted before moving to opposite side. #17199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 21.2.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1061,12 +1061,17 @@ export class IgxForOfDirective<T, U extends T[] = T[]> extends IgxForOfToken<T,U | |
|
|
||
| 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); | ||
|
|
||
| // embView and view both refer to the same collections | ||
| this.updateTemplateContext(embView.context, i); | ||
|
|
||
| // 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(); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: In order to minimize this change since it is problematic so far only in Elements, this can be an option that can be enabled for the ForOf and be enabled only for the HGrid on Elements.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO from a performance perspective this is fine, since this is only for small scrolls where a single view is moved and re-rendered. So an additional check should not cause a performance degradation. |
||
|
|
||
| container.insert(view); | ||
|
skrustev marked this conversation as resolved.
|
||
| this._embeddedViews.push(embView); | ||
|
skrustev marked this conversation as resolved.
|
||
| } | ||
|
|
@@ -1081,12 +1086,15 @@ export class IgxForOfDirective<T, U extends T[] = T[]> extends IgxForOfToken<T,U | |
| const container = this.dc.instance._vcr as ViewContainerRef; | ||
| 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); | ||
|
|
||
| this.updateTemplateContext(embView.context, i); | ||
| view.detectChanges(); | ||
|
|
||
| container.insert(view, 0); | ||
| this._embeddedViews.unshift(embView); | ||
|
skrustev marked this conversation as resolved.
|
||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.