Skip to content

Commit 4e3f18d

Browse files
authored
Merge branch 'master' into mpopov/chip-z-index
2 parents e469600 + 7b9fc55 commit 4e3f18d

21 files changed

+243
-122
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"test:lib:azure:tgrid": "ng test igniteui-angular --watch=false --no-progress --karma-config=./projects/igniteui-angular/karma.azure.tree-grid.conf.js",
2121
"test:lib:azure:hgrid": "ng test igniteui-angular --watch=false --no-progress --karma-config=./projects/igniteui-angular/karma.azure.hierarchical-grid.conf.js",
2222
"test:lib:azure:others": "ng test igniteui-angular --watch=false --no-progress --karma-config=./projects/igniteui-angular/karma.azure.non-grid.conf.js",
23-
"test:lib:watch": "ng test igniteui-angular",
23+
"test:lib:watch": "ng test igniteui-angular --karma-config=./projects/igniteui-angular/karma.watch.conf.js",
2424
"test:schematics": "ts-node --project projects/igniteui-angular/migrations/tsconfig.json ./node_modules/jasmine/bin/jasmine.js ./projects/igniteui-angular/migrations/**/*.spec.ts ./projects/igniteui-angular/schematics/**/*.spec.ts",
2525
"test:styles": "ts-node --skip-project ./node_modules/jasmine/bin/jasmine.js ./projects/igniteui-angular/src/lib/core/styles/spec/tests.ts",
2626
"build:lib": "ng build igniteui-angular --configuration production && gulp buildStyle",
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Karma configuration file, see link for more information
2+
// https://karma-runner.github.io/1.0/config/configuration-file.html
3+
4+
module.exports = function (config) {
5+
config.set({
6+
basePath: '',
7+
frameworks: ['jasmine', 'jasmine-spec-tags', '@angular-devkit/build-angular'],
8+
files: [
9+
{ pattern: '../../node_modules/hammerjs/hammer.min.js', watched: false },
10+
{ pattern: '../../node_modules/hammer-simulator/index.js', watched: false },
11+
{ pattern: './test.css', watched: false },
12+
{ pattern: '../../dist/igniteui-angular/styles/igniteui-angular.css', watched: false }
13+
],
14+
plugins: [
15+
require('karma-jasmine'),
16+
require('karma-chrome-launcher'),
17+
require('karma-jasmine-spec-tags'),
18+
require('karma-jasmine-html-reporter'),
19+
require('karma-spec-reporter'),
20+
require('@angular-devkit/build-angular/plugins/karma')
21+
],
22+
client: {
23+
clearContext: false, // leave Jasmine Spec Runner output visible in browser
24+
jasmine: {
25+
random: false
26+
},
27+
tagPrefix: '#',
28+
skipTags: 'perf'
29+
},
30+
reporters: ['progress'],
31+
specReporter: {
32+
suppressSkipped: true,
33+
suppressErrorSummary: false,
34+
suppressFailed: false,
35+
suppressPassed: false,
36+
showSpecTiming: false,
37+
failFast: false
38+
},
39+
port: 9876,
40+
colors: true,
41+
logLevel: config.LOG_INFO,
42+
autoWatch: true,
43+
browsers: ['Chrome'],
44+
singleRun: false
45+
});
46+
};

projects/igniteui-angular/src/lib/checkbox/checkbox.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ export class IgxCheckboxComponent implements ControlValueAccessor, EditorProvide
376376
}
377377
/** @hidden @internal */
378378
@HostListener('click', ['$event'])
379-
public _onCheckboxClick(event: MouseEvent) {
379+
public _onCheckboxClick(event: PointerEvent | MouseEvent) {
380380
// Since the original checkbox is hidden and the label
381381
// is used for styling and to change the checked state of the checkbox,
382382
// we need to prevent the checkbox click event from bubbling up

projects/igniteui-angular/src/lib/directives/template-outlet/template_outlet.directive.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ export class IgxTemplateOutletDirective implements OnChanges {
3131

3232
/**
3333
* The embedded views cache. Collection is key-value paired.
34-
* Key is the template id, value is the embedded view for the related template.
34+
* Key is the template type, value is another key-value paired collection
35+
* where the key is the template id and value is the embedded view for the related template.
3536
*/
36-
private _embeddedViewsMap: Map<string, EmbeddedViewRef<any>> = new Map();
37+
private _embeddedViewsMap: Map<string, Map<any, EmbeddedViewRef<any>>> = new Map();
3738

3839
constructor(public _viewContainerRef: ViewContainerRef, private _zone: NgZone, public cdr: ChangeDetectorRef) {
3940
}
@@ -49,19 +50,23 @@ export class IgxTemplateOutletDirective implements OnChanges {
4950
}
5051

5152
public cleanCache() {
52-
this._embeddedViewsMap.forEach((item) => {
53-
if (!item.destroyed) {
54-
item.destroy();
55-
}
53+
this._embeddedViewsMap.forEach((collection) => {
54+
collection.forEach((item => {
55+
if (!item.destroyed) {
56+
item.destroy();
57+
}
58+
}));
59+
collection.clear();
5660
});
5761
this._embeddedViewsMap.clear();
5862
}
5963

6064
public cleanView(tmplID) {
61-
const embView = this._embeddedViewsMap.get(tmplID);
65+
const embViewCollection = this._embeddedViewsMap.get(tmplID.type);
66+
const embView = embViewCollection?.get(tmplID.id);
6267
if (embView) {
6368
embView.destroy();
64-
this._embeddedViewsMap.delete(tmplID);
69+
this._embeddedViewsMap.get(tmplID.type).delete(tmplID.id);
6570
}
6671
}
6772

@@ -81,9 +86,11 @@ export class IgxTemplateOutletDirective implements OnChanges {
8186
// if context contains a template id, check if we have a view for that template already stored in the cache
8287
// if not create a copy and add it to the cache in detached state.
8388
// Note: Views in detached state do not appear in the DOM, however they remain stored in memory.
84-
const res = this._embeddedViewsMap.get(this.igxTemplateOutletContext['templateID']);
89+
const resCollection = this._embeddedViewsMap.get(this.igxTemplateOutletContext['templateID'].type);
90+
const res = resCollection?.get(this.igxTemplateOutletContext['templateID'].id);
8591
if (!res) {
86-
this._embeddedViewsMap.set(this.igxTemplateOutletContext['templateID'], this._viewRef);
92+
this._embeddedViewsMap.set(this.igxTemplateOutletContext['templateID'].type,
93+
new Map([[this.igxTemplateOutletContext['templateID'].id, this._viewRef]]));
8794
}
8895
}
8996
}
@@ -115,7 +122,7 @@ export class IgxTemplateOutletDirective implements OnChanges {
115122
// use view for specific template cached in the current template outlet
116123
const tmplID = this.igxTemplateOutletContext['templateID'];
117124
const cachedView = tmplID ?
118-
this._embeddedViewsMap.get(tmplID) :
125+
this._embeddedViewsMap.get(tmplID.type)?.get(tmplID.id) :
119126
null;
120127
// if view exists, but template has been changed and there is a view in the cache with the related template
121128
// then detach old view and insert the stored one with the matching template
@@ -171,7 +178,7 @@ export class IgxTemplateOutletDirective implements OnChanges {
171178
const movedView = this.igxTemplateOutletContext['moveView'];
172179
const tmplID = this.igxTemplateOutletContext['templateID'];
173180
const cachedView = tmplID ?
174-
this._embeddedViewsMap.get(tmplID) :
181+
this._embeddedViewsMap.get(tmplID.type)?.get(tmplID.id) :
175182
null;
176183
const shouldRecreate = this._shouldRecreateView(changes);
177184
if (movedView) {

projects/igniteui-angular/src/lib/grids/cell.component.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { ColumnType } from './common/column.interface';
2525
import { RowType } from './common/row.interface';
2626
import { GridSelectionMode } from './common/enums';
2727
import { GridType } from './common/grid.interface';
28-
import { getCurrencySymbol, getLocaleCurrencyCode} from '@angular/common';
28+
import { getCurrencySymbol, getLocaleCurrencyCode } from '@angular/common';
2929
import { GridColumnDataType } from '../data-operations/data-util';
3030
import { IgxRowDirective } from './row.directive';
3131
import { ISearchInfo } from './common/events';
@@ -165,11 +165,18 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
165165
* @memberof IgxGridCellComponent
166166
*/
167167
public get context(): any {
168-
return {
168+
const ctx = {
169169
$implicit: this.value,
170-
cell: this.getCellType(),
171-
additionalTemplateContext: this.column.additionalTemplateContext
170+
additionalTemplateContext: this.column.additionalTemplateContext,
172171
};
172+
/* Turns the `cell` property from the template context object into lazy-evaluated one.
173+
* Otherwise on each detection cycle the cell template is recreating N cell instances where
174+
* N = number of visible cells in the grid, leading to massive performance degradation in large grids.
175+
*/
176+
Object.defineProperty(ctx, 'cell', {
177+
get: () => this.getCellType()
178+
});
179+
return ctx;
173180
}
174181

175182
/**
@@ -804,7 +811,7 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
804811
cell = this.grid.crudService.createCell(this);
805812
}
806813
cell.editValue = val;
807-
const args = this.gridAPI.update_cell(cell);
814+
this.gridAPI.update_cell(cell);
808815
this.grid.crudService.endCellEdit();
809816
this.cdr.markForCheck();
810817
}
@@ -831,7 +838,7 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
831838
}
832839
return;
833840
}
834-
if(this.platformUtil.isFirefox) {
841+
if (this.platformUtil.isFirefox) {
835842
event.preventDefault();
836843
}
837844
this.selectionService.pointerDown(this.selectionNode, event.shiftKey, event.ctrlKey);
@@ -1034,6 +1041,6 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
10341041
}
10351042

10361043
private getCellType(): CellType {
1037-
return new IgxGridCell(this.grid, this.row.index, this.column.field);
1044+
return new IgxGridCell(this.grid, this.intRow.index, this.column.field);
10381045
}
10391046
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5848,7 +5848,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
58485848
*/
58495849
public cachedViewLoaded(args: ICachedViewLoadedEventArgs) {
58505850
if (this.hasHorizontalScroll()) {
5851-
const tmplId = args.context.templateID;
5851+
const tmplId = args.context.templateID.type;
58525852
const index = args.context.index;
58535853
args.view.detectChanges();
58545854
this.zone.onStable.pipe(first()).subscribe(() => {

projects/igniteui-angular/src/lib/grids/grid-public-cell.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export class IgxGridCell implements CellType {
3535
this._rowIndex = row;
3636
} else {
3737
this._row = row;
38+
this._rowIndex = row.index;
3839
}
3940
if (typeof column === 'string') {
4041
this._columnField = column;
@@ -52,7 +53,7 @@ export class IgxGridCell implements CellType {
5253
* @memberof IgxGridCell
5354
*/
5455
public get row(): RowType {
55-
return this._row || this.grid.createRow(this._rowIndex);
56+
return this.grid.createRow(this._rowIndex);
5657
}
5758

5859
/**

projects/igniteui-angular/src/lib/grids/grid/grid-add-row.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ describe('IgxGrid - Row Adding #grid', () => {
845845
});
846846
fixture.detectChanges();
847847

848-
const groupRows = grid.groupsRowList.toArray();
848+
let groupRows = grid.groupsRowList.toArray();
849849
grid.toggleGroup(groupRows[2].groupRow);
850850
fixture.detectChanges();
851851
expect(groupRows[2].expanded).toBeFalse();
@@ -867,6 +867,7 @@ describe('IgxGrid - Row Adding #grid', () => {
867867
fixture.detectChanges();
868868
const row2 = grid.getRowByKey(addedRec[grid.primaryKey]);
869869

870+
groupRows = grid.groupsRowList.toArray();
870871
expect(row2).not.toBeNull();
871872
expect(groupRows[2].expanded).toBeTrue();
872873
expect(groupRows[2].groupRow.records.length).toEqual(2);

0 commit comments

Comments
 (0)