Skip to content

Commit afb6fe0

Browse files
authored
Merge pull request #13720 from IgniteUI/bpachilova/fix-13688-17.0.x
fix(igxForOf): do not reset state.startIndex with scroll position - 17.0.x
2 parents c5fdcb5 + e6a03b1 commit afb6fe0

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,38 @@ describe('IgxForOf directive -', () => {
189189
expect(state.startIndex).toBe(1);
190190
});
191191

192+
it('should display the correct chunk items on resizing the container', () => {
193+
// initially the container's width is narrow enough to be scrollable
194+
fix.componentInstance.width = '200px';
195+
fix.componentInstance.cols = [
196+
{ field: '1', width: 100 },
197+
{ field: '2', width: 100 },
198+
{ field: '3', width: 100 },
199+
{ field: '4', width: 100 },
200+
{ field: '5', width: 100 }
201+
];
202+
fix.detectChanges();
203+
204+
expect(displayContainer).not.toBeNull();
205+
206+
// scroll the container so that at least the first col is out of view
207+
fix.componentInstance.scrollLeft(displayContainer.clientWidth);
208+
fix.detectChanges();
209+
210+
fix.componentInstance.childVirtDirs.toArray().forEach(element => {
211+
expect(element.state.startIndex).not.toBe(0);
212+
});
213+
214+
// the container's width is assigned as wide as to display all cols
215+
fix.componentInstance.width = '600px';
216+
fix.detectChanges();
217+
218+
const secondRecChildren = fix.nativeElement.querySelectorAll(DISPLAY_CONTAINER)[1].children;
219+
for (let i = 0; i < secondRecChildren.length; i++) {
220+
expect(secondRecChildren[i].textContent)
221+
.toBe(fix.componentInstance.data[1][i + 1].toString());
222+
}
223+
});
192224
});
193225

194226
describe('vertical virtual component', () => {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,6 @@ export class IgxForOfDirective<T, U extends T[] = T[]> extends IgxForOfToken<T,U
888888
public resetScrollPosition() {
889889
this.scrollPosition = 0;
890890
this.scrollComponent.scrollAmount = 0;
891-
this.state.startIndex = 0;
892891
}
893892

894893
/**

0 commit comments

Comments
 (0)