Skip to content

Commit c4e6565

Browse files
authored
Merge branch '16.1.x' into gedinakova/fflateUpdate-16.1
2 parents 71237db + da87260 commit c4e6565

File tree

5 files changed

+54
-3
lines changed

5 files changed

+54
-3
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
@@ -862,7 +862,6 @@ export class IgxForOfDirective<T, U extends T[] = T[]> implements OnInit, OnChan
862862
public resetScrollPosition() {
863863
this.scrollPosition = 0;
864864
this.scrollComponent.scrollAmount = 0;
865-
this.state.startIndex = 0;
866865
}
867866

868867
/**

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3698,6 +3698,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
36983698
public resetCaches(recalcFeatureWidth = true) {
36993699
if (recalcFeatureWidth) {
37003700
this._headerFeaturesWidth = NaN;
3701+
this.summaryService.summaryHeight = 0;
37013702
}
37023703
this.resetForOfCache();
37033704
this.resetColumnsCaches();

projects/igniteui-angular/src/lib/grids/state.directive.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,25 @@ describe('IgxGridState - input properties #grid', () => {
397397
expect(grid.columnInit.emit).toHaveBeenCalledTimes(columnsStateObject.columns.length);
398398
});
399399

400+
it('setState should correctly restore grid columns with Column Groups and same headers', () => {
401+
const fix = TestBed.createComponent(IgxGridStateComponent);
402+
fix.detectChanges();
403+
const state = fix.componentInstance.state;
404+
/* eslint-disable max-len */
405+
const initialState = '{"columns":[{"pinned":true,"sortable":true,"filterable":true,"editable":false,"sortingIgnoreCase":true,"filteringIgnoreCase":true,"headerClasses":"testCss","headerGroupClasses":"","maxWidth":"300px","groupable":false,"movable":false,"hidden":false,"dataType":"number","hasSummary":false,"field":"ProductID","width":"150px","header":"Product ID","resizable":true,"searchable":false,"parent":null,"columnGroup":false,"disableHiding":false,"disablePinning":false},{"pinned":false,"sortable":true,"filterable":true,"editable":false,"sortingIgnoreCase":true,"filteringIgnoreCase":true,"headerClasses":"","headerGroupClasses":"","maxWidth":"300px","groupable":true,"movable":false,"hidden":false,"dataType":"string","hasSummary":false,"field":"ProductName","width":"150px","header":"Prodyct Name","resizable":true,"searchable":true,"selectable":false,"parent":null,"columnGroup":false,"disableHiding":false,"disablePinning":false},{"pinned":false,"sortable":false,"filterable":true,"editable":true,"sortingIgnoreCase":true,"filteringIgnoreCase":true,"headerClasses":"","headerGroupClasses":"","maxWidth":"300px","groupable":false,"movable":false,"hidden":false,"dataType":"boolean","hasSummary":true,"field":"InStock","width":"140px","header":"In Stock","resizable":true,"searchable":true,"parent":null,"columnGroup":false,"disableHiding":false,"disablePinning":true},{"pinned":false,"sortable":true,"filterable":false,"editable":true,"sortingIgnoreCase":true,"filteringIgnoreCase":true,"headerClasses":"","headerGroupClasses":"","maxWidth":"300px","groupable":true,"movable":false,"hidden":false,"dataType":"date","hasSummary":false,"field":"OrderDate","width":"110px","header":"Date ordered","resizable":false,"searchable":true,"parent":null,"columnGroup":false,"disableHiding":false,"disablePinning":false}]}';
406+
const columnsState = '{"columns":[{"pinned":false,"sortable":false,"filterable":false,"editable":false,"sortingIgnoreCase":true,"filteringIgnoreCase":true,"headerClasses":"","headerGroupClasses":"","groupable":false,"movable":false,"hidden":false,"dataType":"string","hasSummary":false,"field":"ProductID","width":"199px","header":"General Information","resizable":true,"searchable":true,"selectable":true,"parent":null,"columnGroup":false,"disableHiding":false},{"pinned":false,"sortable":false,"filterable":true,"editable":false,"sortingIgnoreCase":true,"filteringIgnoreCase":true,"headerClasses":"","headerGroupClasses":"","groupable":false,"movable":false,"hidden":false,"dataType":"string","hasSummary":false,"width":"398px","header":"General Information","resizable":false,"searchable":true,"selectable":true,"parent":null,"columnGroup":true,"disableHiding":false},{"pinned":false,"sortable":true,"filterable":true,"editable":false,"sortingIgnoreCase":true,"filteringIgnoreCase":true,"headerClasses":"","headerGroupClasses":"","groupable":false,"movable":false,"hidden":false,"dataType":"string","hasSummary":false,"field":"ProductName","width":"199px","header":"","resizable":true,"searchable":true,"selectable":true,"parent":"General Information","columnGroup":false,"disableHiding":false},{"pinned":false,"sortable":true,"filterable":true,"editable":false,"sortingIgnoreCase":true,"filteringIgnoreCase":true,"headerClasses":"","headerGroupClasses":"","groupable":false,"movable":false,"hidden":false,"dataType":"string","hasSummary":false,"field":"UnitsInStock","width":"199px","header":"","resizable":true,"searchable":true,"selectable":true,"parent":"General Information","columnGroup":false,"disableHiding":false},{"pinned":false,"sortable":true,"filterable":true,"editable":false,"sortingIgnoreCase":true,"filteringIgnoreCase":true,"headerClasses":"","headerGroupClasses":"","groupable":false,"movable":false,"hidden":false,"dataType":"string","hasSummary":false,"field":"InStock","width":"199px","header":"","resizable":true,"searchable":true,"selectable":true,"parent":null,"columnGroup":false,"disableHiding":false}],"filtering":{"filteringOperands":[],"operator":0},"advancedFiltering":{},"sorting":[],"groupBy":{"expressions":[],"expansion":[],"defaultExpanded":true},"cellSelection":[],"rowSelection":[],"columnSelection":[],"rowPinning":[],"expansion":[],"moving":true,"rowIslands":[]}';
407+
/* eslint-enable max-len */
408+
const columnsStateObject = JSON.parse(columnsState);
409+
let gridState = state.getState(true, 'columns');
410+
expect(gridState).toBe(initialState);
411+
expect(() => {
412+
state.setState(columnsStateObject);
413+
}).not.toThrow();
414+
415+
gridState = state.getState(false, 'columns') as IGridState;
416+
HelperFunctions.verifyColumns(columnsStateObject.columns, gridState);
417+
});
418+
400419
it('setState should correctly restore grid paging state from string', () => {
401420
const fix = TestBed.createComponent(IgxGridStateComponent);
402421
fix.detectChanges();

projects/igniteui-angular/src/lib/grids/state.directive.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export class IgxGridStateDirective {
216216
Object.assign(ref1.instance, colState);
217217
ref1.instance.grid = context.currGrid;
218218
if (ref1.instance.parent) {
219-
const columnGroup: IgxColumnGroupComponent = newColumns.find(e => e.header === ref1.instance.parent);
219+
const columnGroup: IgxColumnGroupComponent = newColumns.find(e => e.header === ref1.instance.parent && e.columnGroup);
220220
columnGroup.children.reset([...columnGroup.children.toArray(), ref1.instance]);
221221
ref1.instance.parent = columnGroup;
222222
}
@@ -227,7 +227,7 @@ export class IgxGridStateDirective {
227227
Object.assign(ref.instance, colState);
228228
ref.instance.grid = context.currGrid;
229229
if (ref.instance.parent) {
230-
const columnGroup: IgxColumnGroupComponent = newColumns.find(e => e.header === ref.instance.parent);
230+
const columnGroup: IgxColumnGroupComponent = newColumns.find(e => e.header === ref.instance.parent && e.columnGroup);
231231
if (columnGroup) {
232232
ref.instance.parent = columnGroup;
233233
columnGroup.children.reset([...columnGroup.children.toArray(), ref.instance]);

0 commit comments

Comments
 (0)