Skip to content

Commit bec9363

Browse files
authored
Merge pull request #14363 from IgniteUI/mdragnev/fix-14039-17.2.x
fix(forof): Do not force setting master on each change. Set new sync master if the old one is not in the DOM
2 parents 2c61d3f + a15072b commit bec9363

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

projects/igniteui-angular/src/lib/directives/for-of/for_of.directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,7 @@ export class IgxGridForOfDirective<T, U extends T[] = T[]> extends IgxForOfDirec
16211621
}
16221622
if (this.igxForScrollOrientation === 'horizontal') {
16231623
// in case collection has changes, reset sync service
1624-
this.syncService.setMaster(this, true);
1624+
this.syncService.setMaster(this, this.igxGridForOfUniqueSizeCache);
16251625
}
16261626
}
16271627
const defaultItemSize = 'igxForItemSize';

projects/igniteui-angular/src/lib/directives/for-of/for_of.sync.service.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ export class IgxForOfSyncService {
2121
*/
2222
public setMaster(directive: IgxGridForOfDirective<any, any[]>, forced = false) {
2323
const orientation = directive.igxForScrollOrientation;
24+
// in case master is not in dom, set a new master
25+
const isMasterInDom = this._master.get(orientation)?.dc?.instance?._viewContainer.element.nativeElement.isConnected;
26+
if (!isMasterInDom) {
27+
forced = true;
28+
}
2429
if (orientation && (forced || !this._master.has(orientation))) {
2530
this._master.set(orientation, directive);
2631
}

0 commit comments

Comments
 (0)