Skip to content

Commit a367ab7

Browse files
authored
Merge branch 'master' into navbar-title-flex-master
2 parents 0a73482 + c7f70c9 commit a367ab7

File tree

7 files changed

+110
-10
lines changed

7 files changed

+110
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ All notable changes for each version of this project will be documented in this
2222
### General
2323
- `igxGrid`, `igxHierarchicalGrid`, `igxTreeGrid`
2424
- 'oddRowCSS' and 'evenRowCSS' properties has been deprecated
25+
- `IgxForOf` - now takes margins into account when calculating the space that each element takes.
26+
_Note:_ If your virtualized items contain margins, please calculate them into the `itemSize` value for the best possible initial virtualized state.
27+
28+
## 12.1.6
2529

2630
## 12.1.6
2731

projects/igniteui-angular/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@
7777
"@igniteui/material-icons-extended": "^2.8.0"
7878
},
7979
"peerDependencies": {
80-
"@angular/common": "^12.1.1",
81-
"@angular/core": "^12.1.1",
82-
"@angular/animations": "^12.1.1",
83-
"@angular/forms": "^12.1.1",
80+
"@angular/common": "^12.2.0",
81+
"@angular/core": "^12.2.0",
82+
"@angular/animations": "^12.2.0",
83+
"@angular/forms": "^12.2.0",
8484
"web-animations-js": "^2.3.2"
8585
},
8686
"igxDevDependencies": {
87-
"@igniteui/angular-schematics": "~12.1.810"
87+
"@igniteui/angular-schematics": "~12.2.820-alpha.0"
8888
},
8989
"ng-update": {
9090
"migrations": "./migrations/migration-collection.json"

projects/igniteui-angular/src/lib/data-operations/filtering-strategy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export class FormattedValuesFilteringStrategy extends FilteringStrategy {
134134
let value = resolveNestedPath(rec, fieldName);
135135

136136
value = column.formatter && this.shouldApplyFormatter(fieldName) ?
137-
column.formatter(value) : value && (isDate || isTime) ? parseDate(value) : value;
137+
column.formatter(value, rec) : value && (isDate || isTime) ? parseDate(value) : value;
138138

139139
return value;
140140
}

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

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,33 @@ describe('IgxForOf directive -', () => {
324324
chunkSize = (virtualContainer as any)._calcMaxChunkSize();
325325
expect(chunkSize).toEqual(10);
326326
});
327+
328+
it('should take item margins into account when calculating the size cache', async () => {
329+
fix.componentInstance.height = '600px';
330+
fix.componentInstance.itemSize = '100px';
331+
const virtualContainer = fix.componentInstance.parentVirtDir;
332+
virtualContainer.igxForSizePropName = 'height';
333+
fix.componentInstance.data = [
334+
{ 1: '1', height: '100px', margin: '30px' },
335+
{ 1: '2', height: '100px', margin: '0px' },
336+
{ 1: '3', height: '100px', margin: '0px' },
337+
{ 1: '4', height: '100px', margin: '0px' },
338+
{ 1: '5', height: '100px', margin: '0px' },
339+
{ 1: '6', height: '100px', margin: '0px' },
340+
{ 1: '7', height: '100px', margin: '0px' },
341+
{ 1: '8', height: '100px', margin: '30px' },
342+
{ 1: '9', height: '100px', margin: '30px' },
343+
{ 1: '10', height: '100px', margin: '30px' }
344+
];
345+
fix.detectChanges();
346+
await wait(200);
347+
const cache = (fix.componentInstance.parentVirtDir as any).heightCache;
348+
expect(cache).toEqual([130, 100, 100, 100, 100, 100, 100, 100, 100, 100]);
349+
fix.componentInstance.scrollTop(400);
350+
fix.detectChanges();
351+
await wait(200);
352+
expect(cache).toEqual([130, 100, 100, 100, 100, 100, 100, 130, 130, 130]);
353+
});
327354
});
328355

329356
describe('vertical and horizontal virtual component', () => {
@@ -1185,7 +1212,7 @@ describe('IgxForOf directive -', () => {
11851212
const secondForOf = fix.componentInstance.secondForOfDir;
11861213
expect(secondForOf.state.startIndex).toBe(0);
11871214
});
1188-
});
1215+
});
11891216
});
11901217

11911218
class DataGenerator {
@@ -1401,7 +1428,9 @@ export class VirtualComponent {
14011428
[igxForScrollOrientation]="'vertical'"
14021429
[igxForContainerSize]='height'
14031430
[igxForItemSize]='itemSize'>
1404-
<div [style.display]="'flex'" [style.height]="rowData.height || itemSize || '50px'">
1431+
<div [style.display]="'flex'"
1432+
[style.height]="rowData.height || itemSize || '50px'"
1433+
[style.margin-top]="rowData.margin || '0px'">
14051434
<div [style.min-width]=cols[0].width>{{rowData['1']}}</div>
14061435
<div [style.min-width]=cols[1].width>{{rowData['2']}}</div>
14071436
<div [style.min-width]=cols[2].width>{{rowData['3']}}</div>

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
735735

736736
/**
737737
* @hidden
738-
* Function that recaculates and updates cache sizes.
738+
* Function that recalculates and updates cache sizes.
739739
*/
740740
public recalcUpdateSizes() {
741741
const dimension = this.igxForScrollOrientation === 'horizontal' ?
@@ -753,8 +753,9 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
753753
if (!this.isRemote && !this.igxForOf[index]) {
754754
continue;
755755
}
756+
const margin = this.getMargin(rNode, dimension);
756757
const oldVal = dimension === 'height' ? this.heightCache[index] : this.igxForOf[index][dimension];
757-
const newVal = dimension === 'height' ? h : rNode.clientWidth;
758+
const newVal = (dimension === 'height' ? h : rNode.clientWidth) + margin;
758759
if (dimension === 'height') {
759760
this.heightCache[index] = newVal;
760761
} else {
@@ -855,6 +856,8 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
855856

856857
this.dc.instance._viewContainer.element.nativeElement.style.top = -(scrollOffset) + 'px';
857858

859+
this._zone.onStable.pipe(first()).subscribe(this.recalcUpdateSizes.bind(this));
860+
858861
this.dc.changeDetectorRef.detectChanges();
859862
if (prevStartIndex !== this.state.startIndex) {
860863
this.chunkLoad.emit(this.state);
@@ -1404,6 +1407,16 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
14041407
this.scrollPosition = newSize === this.scrollPosition ? newSize + 1 : newSize;
14051408
}
14061409
}
1410+
1411+
private getMargin(node, dimension: string): number {
1412+
const styles = window.getComputedStyle(node);
1413+
if (dimension === 'height') {
1414+
return parseFloat(styles['marginTop']) +
1415+
parseFloat(styles['marginBottom']) || 0;
1416+
}
1417+
return parseFloat(styles['marginLeft']) +
1418+
parseFloat(styles['marginRight']) || 0;
1419+
}
14071420
}
14081421

14091422
export const getTypeNameForDebugging = (type: any): string => type.name || typeof type;

projects/igniteui-angular/src/lib/grids/grid/grid-filtering-advanced.spec.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,6 +1807,40 @@ describe('IgxGrid - Advanced Filtering #grid - ', () => {
18071807
expect(rows.length).toEqual(3, 'Wrong filtered rows count');
18081808
}));
18091809

1810+
it('Should filter by cells formatted data when using FormattedValuesFilteringStrategy with rowData', fakeAsync(() => {
1811+
const formattedStrategy = new FormattedValuesFilteringStrategy(['ProductName']);
1812+
grid.filterStrategy = formattedStrategy;
1813+
const anotherFieldFormatter = (value: any, rowData: any) => rowData.ID + ':' + value;
1814+
grid.columns[1].formatter = anotherFieldFormatter;
1815+
fix.detectChanges();
1816+
1817+
grid.openAdvancedFilteringDialog();
1818+
tick(200);
1819+
fix.detectChanges();
1820+
1821+
// Add root group.
1822+
GridFunctions.clickAdvancedFilteringInitialAddGroupButton(fix, 0);
1823+
tick(100);
1824+
fix.detectChanges();
1825+
1826+
// Add a new expression
1827+
selectColumnInEditModeExpression(fix, 1); // Select 'ProductName' column.
1828+
selectOperatorInEditModeExpression(fix, 0); // Select 'Contains' operator.
1829+
const input = GridFunctions.getAdvancedFilteringValueInput(fix).querySelector('input');
1830+
UIInteractions.clickAndSendInputElementValue(input, '1:', fix); // Type filter value.
1831+
1832+
// Commit the populated expression.
1833+
GridFunctions.clickAdvancedFilteringExpressionCommitButton(fix);
1834+
tick(100);
1835+
fix.detectChanges();
1836+
GridFunctions.clickAdvancedFilteringApplyButton(fix);
1837+
tick(100);
1838+
fix.detectChanges();
1839+
1840+
const rows = GridFunctions.getRows(fix);
1841+
expect(rows.length).toEqual(1, 'Wrong filtered rows count');
1842+
}));
1843+
18101844
describe('Context Menu - ', () => {
18111845
it('Should discard added group when clicking its operator line without having a single expression.', fakeAsync(() => {
18121846
// Open Advanced Filtering dialog.

projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2179,6 +2179,25 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
21792179
expect(rows.length).toEqual(2);
21802180
}));
21812181

2182+
it('Should filter by cells formatted data when using FormattedValuesFilteringStrategy with rowData', fakeAsync(() => {
2183+
const formattedStrategy = new FormattedValuesFilteringStrategy(['ProductName']);
2184+
grid.filterStrategy = formattedStrategy;
2185+
const anotherFieldFormatter = (value: any, rowData: any) => rowData.ID + ':' + value;
2186+
grid.columns[1].formatter = anotherFieldFormatter;
2187+
fix.detectChanges();
2188+
2189+
GridFunctions.clickFilterCellChipUI(fix, 'ProductName');
2190+
fix.detectChanges();
2191+
2192+
GridFunctions.typeValueInFilterRowInput('1:', fix);
2193+
tick(DEBOUNCETIME);
2194+
GridFunctions.closeFilterRow(fix);
2195+
fix.detectChanges();
2196+
2197+
const rows = GridFunctions.getRows(fix);
2198+
expect(rows.length).toEqual(1);
2199+
}));
2200+
21822201
it('Should remove pending chip via its close button #9333', fakeAsync(() => {
21832202
GridFunctions.clickFilterCellChipUI(fix, 'Downloads');
21842203
fix.detectChanges();
@@ -3860,6 +3879,7 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
38603879
scrollbar.scrollTop = displayContainer.getBoundingClientRect().height / 2;
38613880
await wait(200);
38623881
fix.detectChanges();
3882+
await wait(100);
38633883

38643884
// Type string in search box
38653885
const inputNativeElement = GridFunctions.getExcelStyleSearchComponentInput(fix, searchComponent);

0 commit comments

Comments
 (0)