Skip to content

Commit 5a8f77d

Browse files
authored
Merge branch '9.0.x' into hPopov/refactor-hGrid-selection-tests-90x
2 parents e0e9c50 + 261aab9 commit 5a8f77d

27 files changed

+1095
-1255
lines changed

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

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ describe('IgxForOf directive -', () => {
197197
horizontalScroller = fix.nativeElement.querySelector('igx-horizontal-virtual-helper');
198198
});
199199

200+
200201
it('should initialize directive with vertical virtualization', async () => {
201202
expect(displayContainer).not.toBeNull();
202203
expect(verticalScroller).not.toBeNull();
@@ -1088,6 +1089,57 @@ describe('IgxForOf directive -', () => {
10881089
}
10891090
});
10901091
});
1092+
1093+
describe('on destroy', () => {
1094+
let fix: ComponentFixture<VerticalVirtualDestroyComponent>;
1095+
1096+
configureTestSuite();
1097+
beforeAll(async(() => {
1098+
TestBed.configureTestingModule({
1099+
declarations: [
1100+
TestIgxForOfDirective,
1101+
VerticalVirtualDestroyComponent
1102+
],
1103+
imports: [IgxForOfModule],
1104+
providers: [{ provide: NgZone, useFactory: () => zone = new TestNgZone() }]
1105+
}).compileComponents();
1106+
}));
1107+
1108+
beforeEach(() => {
1109+
fix = TestBed.createComponent(VerticalVirtualDestroyComponent);
1110+
fix.componentInstance.data = dg.generateVerticalData(fix.componentInstance.cols);
1111+
fix.componentRef.hostView.detectChanges();
1112+
fix.detectChanges();
1113+
});
1114+
it('should reset scroll position if component is destroyed and recreated.', async () => {
1115+
let scrollComponent = fix.debugElement.query(By.css(VERTICAL_SCROLLER)).componentInstance;
1116+
expect(scrollComponent.scrollAmount).toBe(0);
1117+
expect(scrollComponent.destroyed).toBeFalsy();
1118+
1119+
scrollComponent.nativeElement.scrollTop = 500;
1120+
fix.detectChanges();
1121+
await wait();
1122+
expect(scrollComponent.scrollAmount).toBe(500);
1123+
1124+
fix.componentInstance.exists = false;
1125+
fix.detectChanges();
1126+
await wait();
1127+
1128+
expect(scrollComponent.destroyed).toBeTruthy();
1129+
1130+
fix.componentInstance.exists = true;
1131+
fix.detectChanges();
1132+
await wait();
1133+
1134+
scrollComponent = fix.debugElement.query(By.css(VERTICAL_SCROLLER)).componentInstance;
1135+
expect(scrollComponent.scrollAmount).toBe(0);
1136+
expect(scrollComponent.destroyed).toBeFalsy();
1137+
1138+
displayContainer = fix.nativeElement.querySelector(DISPLAY_CONTAINER);
1139+
const firstInnerDisplayContainer = displayContainer.children[0];
1140+
expect(firstInnerDisplayContainer.children[0].textContent).toBe('0');
1141+
});
1142+
});
10911143
});
10921144

10931145
class DataGenerator {
@@ -1329,6 +1381,28 @@ export class VerticalVirtualComponent extends VirtualComponent {
13291381
public itemSize = '50px';
13301382
}
13311383

1384+
@Component({
1385+
template: `
1386+
<div *ngIf='exists' #container [style.width]='width' [style.height]='height'>
1387+
<ng-template #scrollContainer igxForTest let-rowData [igxForOf]="data"
1388+
[igxForScrollOrientation]="'vertical'"
1389+
[igxForContainerSize]='height'
1390+
[igxForItemSize]='itemSize'>
1391+
<div [style.display]="'flex'" [style.height]="rowData.height || itemSize || '50px'">
1392+
<div [style.min-width]=cols[0].width>{{rowData['1']}}</div>
1393+
<div [style.min-width]=cols[1].width>{{rowData['2']}}</div>
1394+
<div [style.min-width]=cols[2].width>{{rowData['3']}}</div>
1395+
<div [style.min-width]=cols[3].width>{{rowData['4']}}</div>
1396+
<div [style.min-width]=cols[4].width>{{rowData['5']}}</div>
1397+
</div>
1398+
</ng-template>
1399+
</div>
1400+
`
1401+
})
1402+
export class VerticalVirtualDestroyComponent extends VerticalVirtualComponent {
1403+
public exists = true;
1404+
}
1405+
13321406
/** Only horizontally virtualized component */
13331407
@Component({
13341408
template: `

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
@@ -390,7 +390,7 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
390390
this.scrollComponent = this.syncScrollService.getScrollMaster(this.igxForScrollOrientation);
391391
this.state.chunkSize = this._calculateChunkSize();
392392
this.dc.instance.notVirtual = !(this.igxForContainerSize && this.state.chunkSize < this.igxForOf.length);
393-
if (this.scrollComponent) {
393+
if (this.scrollComponent && !this.scrollComponent.destroyed) {
394394
this.state.startIndex = Math.min(this.getIndexAt(this.scrollPosition, this.sizesCache, 0),
395395
this.igxForOf.length - this.state.chunkSize);
396396
}

projects/igniteui-angular/src/lib/grids/filtering/base/grid-filtering-row.component.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@
6767
[value]="value | igxdate: filteringService.grid.locale"
6868
[readonly]="true"
6969
(keydown)="onInputKeyDown($event)"/>
70-
<igx-suffix *ngIf="value" (keydown)="onClearKeyDown($event)" (click)="clearInput()" tabindex="0">
71-
<igx-icon>clear</igx-icon>
70+
<igx-suffix *ngIf="value">
71+
<igx-icon (keydown)="onCommitKeyDown($event)" (click)="onCommitClick()" tabindex="0">done</igx-icon>
72+
<igx-icon (keydown)="onClearKeyDown($event)" (click)="clearInput()" tabindex="0">clear</igx-icon>
7273
</igx-suffix>
7374
</igx-input-group>
7475
</ng-template>

projects/igniteui-angular/src/lib/grids/filtering/base/grid-filtering-row.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,11 @@ export class IgxGridFilteringRowComponent implements AfterViewInit {
444444
}
445445
requestAnimationFrame(() => {
446446
const focusedElement = document.activeElement;
447-
if (focusedElement.className === 'igx-chip__remove') {
447+
448+
if (focusedElement.className === 'igx-chip__remove' || focusedElement.tagName === 'IGX-DAY-ITEM') {
448449
return;
449450
}
451+
450452
if (!(focusedElement && this.inputGroup.nativeElement.contains(focusedElement))
451453
&& this.dropDownConditions.collapsed) {
452454
this.commitInput();
@@ -494,7 +496,6 @@ export class IgxGridFilteringRowComponent implements AfterViewInit {
494496
*/
495497
public onDateSelected(value: Date) {
496498
this.value = value;
497-
this.commitInput();
498499
}
499500

500501
/**
@@ -543,11 +544,10 @@ export class IgxGridFilteringRowComponent implements AfterViewInit {
543544

544545
public onChipClick(args, item: ExpressionUI) {
545546
if (this._cancelChipClick) {
547+
this._cancelChipClick = false;
546548
return;
547549
}
548550

549-
this._cancelChipClick = false;
550-
551551
this.expressionsList.forEach(ex => ex.isSelected = false);
552552

553553
this.toggleChip(item);

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4365,7 +4365,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
43654365
* @hidden @internal
43664366
*/
43674367
public get outerWidth() {
4368-
return this.hasVerticalSroll() ? this.calcWidth + this.scrollWidth : this.calcWidth;
4368+
return this.hasVerticalScroll() ? this.calcWidth + this.scrollWidth : this.calcWidth;
43694369
}
43704370

43714371
/**
@@ -4458,7 +4458,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
44584458
width = this.getColumnWidthSum();
44594459
}
44604460

4461-
if (this.hasVerticalSroll() && this.width !== null) {
4461+
if (this.hasVerticalScroll() && this.width !== null) {
44624462
width -= this.scrollWidth;
44634463
}
44644464
if ((Number.isFinite(width) || width === null) && width !== this.calcWidth) {
@@ -4489,7 +4489,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
44894489
/**
44904490
* @hidden @internal
44914491
*/
4492-
public hasVerticalSroll() {
4492+
public hasVerticalScroll() {
44934493
if (this._init) { return false; }
44944494
const isScrollable = this.verticalScrollContainer ? this.verticalScrollContainer.isScrollable() : false;
44954495
return !!(this.calcWidth && this.dataView &&
@@ -4577,7 +4577,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
45774577
*/
45784578
this.resetCaches(recalcFeatureWidth);
45794579
this.cdr.detectChanges();
4580-
const hasScroll = this.hasVerticalSroll();
4580+
const hasScroll = this.hasVerticalScroll();
45814581
this.calculateGridWidth();
45824582
this.resetCaches(recalcFeatureWidth);
45834583
this.cdr.detectChanges();
@@ -4593,7 +4593,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
45934593

45944594
this.cdr.detectChanges();
45954595
// in case scrollbar has appeared recalc to size correctly.
4596-
if (hasScroll !== this.hasVerticalSroll()) {
4596+
if (hasScroll !== this.hasVerticalScroll()) {
45974597
this.calculateGridWidth();
45984598
this.cdr.detectChanges();
45994599
}
@@ -4616,7 +4616,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
46164616
let width = this._width;
46174617
if (width === null) {
46184618
let currentWidth = this.calcWidth;
4619-
if (this.hasVerticalSroll()) {
4619+
if (this.hasVerticalScroll()) {
46204620
currentWidth += this.scrollWidth;
46214621
}
46224622
width = currentWidth + 'px';
@@ -4655,8 +4655,8 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
46554655
protected getUnpinnedWidth(takeHidden = false) {
46564656
let width = this.isPercentWidth ?
46574657
this.calcWidth :
4658-
parseInt(this.width, 10) || parseInt(this.hostWidth, 10) || this.calcWidth;
4659-
if (this.hasVerticalSroll() && !this.isPercentWidth) {
4658+
parseInt(this.width, 10) || parseInt(this.hostWidth, 10) || this.calcWidth;
4659+
if (this.hasVerticalScroll() && !this.isPercentWidth) {
46604660
width -= this.scrollWidth;
46614661
}
46624662
return width - this.getPinnedWidth(takeHidden);

projects/igniteui-angular/src/lib/grids/grid/column-pinning.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,20 @@ describe('Column Pinning UI #grid', () => {
249249
});
250250
}));
251251

252+
it('toolbar should contain only pinnable columns', () => {
253+
grid.showToolbar = true;
254+
grid.columnPinning = true;
255+
fix.detectChanges();
256+
257+
let toolbar = grid.toolbar.columnPinningUI;
258+
expect(toolbar.pinnableColumns.length).toBe(5);
259+
260+
grid.columns[0].disablePinning = true;
261+
fix.detectChanges();
262+
263+
toolbar = grid.toolbar.columnPinningUI;
264+
expect(toolbar.pinnableColumns.length).toBe(4);
265+
});
252266
});
253267

254268
describe('', () => {

0 commit comments

Comments
 (0)