Skip to content

Commit b3fdd00

Browse files
authored
Merge branch 'master' into mkirova/fix-6189
2 parents 92d3f53 + c7e03ba commit b3fdd00

File tree

5 files changed

+43
-56
lines changed

5 files changed

+43
-56
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ export class IgxTemplateOutletDirective implements OnChanges {
6363
}
6464

6565
private _recreateView() {
66+
const prevIndex = this._viewRef ? this._viewContainerRef.indexOf(this._viewRef) : -1;
6667
// detach old and create new
67-
if (this._viewRef) {
68-
this._viewContainerRef.detach(this._viewContainerRef.indexOf(this._viewRef));
68+
if (prevIndex !== -1) {
69+
this._viewContainerRef.detach(prevIndex);
6970
}
7071
if (this.igxTemplateOutlet) {
7172
this._viewRef = this._viewContainerRef.createEmbeddedView(

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -862,15 +862,6 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
862862
}
863863
this.grid.expansionStates = expandedStates;
864864
this.grid.notifyChanges();
865-
const isVirtualized = !this.grid.verticalScrollContainer.dc.instance.notVirtual;
866-
// persist focused cell
867-
const el = this.grid.selectionService.activeElement;
868-
if (isVirtualized && el) {
869-
const cell = this.grid.gridAPI.get_cell_by_visible_index(el.row, el.column);
870-
if (cell) {
871-
cell.nativeElement.focus();
872-
}
873-
}
874865
}
875866
}
876867

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6044,4 +6044,16 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
60446044
advancedFilteringDialog.closeDialog();
60456045
}
60466046
}
6047+
6048+
protected _focusActiveCell() {
6049+
// persist focused cell
6050+
const isVirtualized = !this.verticalScrollContainer.dc.instance.notVirtual;
6051+
const el = this.selectionService.activeElement;
6052+
if (isVirtualized && el) {
6053+
const cell = this.gridAPI.get_cell_by_visible_index(el.row, el.column);
6054+
if (cell) {
6055+
cell.nativeElement.focus();
6056+
}
6057+
}
6058+
}
60476059
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,7 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
598598
this.expansionStatesChange.emit(this._expansionStates);
599599
if (this.gridAPI.grid) {
600600
this.cdr.detectChanges();
601+
this._focusActiveCell();
601602
}
602603
}
603604

projects/igniteui-angular/src/lib/select/select.component.spec.ts

Lines changed: 27 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2475,23 +2475,23 @@ describe('igxSelect', () => {
24752475
fixture.detectChanges();
24762476
tick();
24772477
}));
2478-
it('Should NOT throw console Warning for "Expression changed after it was checked"', fakeAsync(() => {
2479-
const firstSelect = fixture.componentInstance.selectComponents.first as IgxSelectComponent;
2480-
spyOn(console, 'warn');
2478+
it('Should NOT throw console Warning for "Expression changed after it was checked"', () => {
2479+
let selectCDR = fixture.componentInstance.select;
24812480

2482-
expect(firstSelect).toBeDefined();
2483-
expect(firstSelect.value).toBe('ID');
2484-
expect(console.warn).toHaveBeenCalledTimes(0);
2481+
expect(selectCDR).toBeDefined();
2482+
expect(selectCDR.value).toBe('ID');
24852483

24862484
fixture.componentInstance.render = !fixture.componentInstance.render;
24872485
fixture.detectChanges();
2488-
tick();
2486+
selectCDR = fixture.componentInstance.select;
2487+
expect(selectCDR).toBeUndefined();
24892488

2490-
const lastSelect = fixture.componentInstance.selectComponents.last as IgxSelectComponent;
2491-
expect(lastSelect).toBeDefined();
2492-
expect(lastSelect.value).toBe('CompanyName');
2493-
expect(console.warn).toHaveBeenCalledTimes(0);
2494-
}));
2489+
fixture.componentInstance.render = !fixture.componentInstance.render;
2490+
fixture.detectChanges();
2491+
selectCDR = fixture.componentInstance.select;
2492+
expect(selectCDR).toBeDefined();
2493+
expect(selectCDR.value).toBe('ID');
2494+
});
24952495
});
24962496

24972497
@Component({
@@ -2822,44 +2822,26 @@ class IgxSelectHeaderFooterComponent implements OnInit {
28222822

28232823
@Component({
28242824
template: `
2825-
<h4>*ngIf test select for 'expression changed...console Warning'</h4>
2826-
<div *ngIf="render">
2827-
<igx-select #select value="ID">
2828-
<label igxLabel>Column</label>
2829-
<igx-select-item *ngFor="let column of columns" [value]="column.field">
2830-
{{column.field}}
2831-
</igx-select-item>
2832-
</igx-select>
2833-
</div>
2834-
<button igxButton (click)="render=!render">toggle render *ngIF</button>
2835-
<div *ngIf="!render">
2836-
<igx-select #select value="CompanyName">
2837-
<label igxLabel>Column</label>
2838-
<igx-select-item *ngFor="let column of columns" [value]="column.field">
2839-
{{column.field}}
2840-
</igx-select-item>
2841-
</igx-select>
2842-
</div>
2843-
`
2825+
<h4>*ngIf test select for 'expression changed...console Warning'</h4>
2826+
<div *ngIf="render">
2827+
<igx-select #selectCDR value="ID">
2828+
<label igxLabel>Column</label>
2829+
<igx-select-item *ngFor="let column of columns" [value]="column.field">
2830+
{{column.field}}
2831+
</igx-select-item>
2832+
</igx-select>
2833+
</div>
2834+
`
28442835
})
28452836
class IgxSelectCDRComponent {
2846-
@ViewChildren(IgxSelectComponent) public selectComponents: QueryList<IgxSelectComponent>;
2837+
@ViewChild('selectCDR', { read: IgxSelectComponent, static: false })
2838+
public select: IgxSelectComponent;
28472839

28482840
public render = true;
28492841
public columns: Array<any> = [
2850-
{ field: 'ID', width: 80, resizable: true, movable: true, type: 'string' },
2851-
{ field: 'CompanyName', width: 150, resizable: true, movable: true, type: 'string' },
2852-
{ field: 'ContactName', width: 150, resizable: true, movable: true, type: 'string' },
2853-
{ field: 'Employees', width: 150, resizable: true, movable: true, type: 'number' },
2854-
{ field: 'ContactTitle', width: 150, resizable: true, movable: true, type: 'string' },
2855-
{ field: 'DateCreated', width: 150, resizable: true, movable: true, type: 'date' },
2856-
{ field: 'Address', width: 150, resizable: true, movable: true, type: 'string' },
2857-
{ field: 'City', width: 150, resizable: true, movable: true, type: 'string' },
2858-
{ field: 'Region', width: 150, resizable: true, movable: true, type: 'string' },
2859-
{ field: 'PostalCode', width: 150, resizable: true, movable: true, type: 'string' },
2860-
{ field: 'Phone', width: 150, resizable: true, movable: true, type: 'string' },
2861-
{ field: 'Fax', width: 150, resizable: true, movable: true, type: 'string' },
2862-
{ field: 'Contract', width: 150, resizable: true, movable: true, type: 'boolean' }
2842+
{ field: 'ID', type: 'string' },
2843+
{ field: 'CompanyName', type: 'string' },
2844+
{ field: 'ContactName', type: 'string' }
28632845
];
28642846
}
28652847
});

0 commit comments

Comments
 (0)