Skip to content

Commit 934703b

Browse files
authored
Merge branch 'master' into mkirova/fix-8393
2 parents 407cd5d + 0f43cea commit 934703b

File tree

10 files changed

+64
-40
lines changed

10 files changed

+64
-40
lines changed

projects/igniteui-angular/migrations/common/UpdateChanges.spec.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ describe('UpdateChanges', () => {
390390
});
391391
spyOn<any>(fs, 'readFileSync').and.callFake(() => JSON.stringify(classJson));
392392

393-
const fileContent =
393+
let fileContent =
394394
`import { Size, Type as someThg } from "igniteui-angular";
395395
import { IgxService, IgxDiffService as eDiffService, Calendar as Calendar } from 'igniteui-angular';
396396
import { Type } from "@angular/core";
@@ -411,7 +411,7 @@ export class Test {
411411
expect(update.getClassChanges()).toEqual(classJson);
412412

413413
update.applyChanges();
414-
expect(appTree.readContent('test.component.ts')).toEqual(
414+
let expectedFileContent =
415415
`import { IgxSize, IgxType as someThg } from "igniteui-angular";
416416
import { IgxService1, IgxNewDiffService as eDiffService, CalendarActual as Calendar } from 'igniteui-angular';
417417
import { Type } from "@angular/core";
@@ -423,8 +423,15 @@ export class Test {
423423
cal: Calendar;
424424
425425
constructor (public router: Router, private _iconService: IgxService1) {}
426-
}`
427-
);
426+
}`;
427+
expect(appTree.readContent('test.component.ts')).toEqual(expectedFileContent);
428+
429+
// with ig feed package:
430+
fileContent = fileContent.replace(/igniteui-angular/g, '@infragistics/igniteui-angular');
431+
expectedFileContent = expectedFileContent.replace(/igniteui-angular/g, '@infragistics/igniteui-angular');
432+
appTree.overwrite('test.component.ts', fileContent);
433+
update.applyChanges();
434+
expect(appTree.readContent('test.component.ts')).toEqual(expectedFileContent);
428435
});
429436

430437
it('should move property value between element tags', done => {

projects/igniteui-angular/migrations/common/tsLogger.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ export class Logger implements ts.server.Logger {
2323
}
2424

2525
public msg(s: string, type: ts.server.Msg = ts.server.Msg.Err) {
26+
if (!this.traceToConsole) { return; }
2627
if (type === ts.server.Msg.Info) {
27-
// TODO: Info ignored for now, hook into context in the future
28-
// console.log(s);
28+
console.log(s);
2929
}
3030
if (type === ts.server.Msg.Err) {
3131
console.error(s);

projects/igniteui-angular/migrations/common/tsUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export function getImportModulePositions(sourceText: string, startsWith: string)
6969
/** Filters out statements to named imports (e.g. `import {x, y}`) from PACKAGE_IMPORT */
7070
const namedImportFilter = (statement: ts.Statement) => {
7171
if (statement.kind === ts.SyntaxKind.ImportDeclaration &&
72-
((statement as ts.ImportDeclaration).moduleSpecifier as ts.StringLiteral).text === IG_PACKAGE_NAME) {
72+
((statement as ts.ImportDeclaration).moduleSpecifier as ts.StringLiteral).text.endsWith(IG_PACKAGE_NAME)) {
7373

7474
const clause = (statement as ts.ImportDeclaration).importClause;
7575
return clause && clause.namedBindings && clause.namedBindings.kind === ts.SyntaxKind.NamedImports;

projects/igniteui-angular/src/lib/calendar/calendar.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ <h2 class="igx-calendar__header-date">
2323
</div>
2424

2525
<div *ngIf="isDefaultView" class="igx-calendar__body" [@animateView]="activeView" (@animateView.done)="viewRendered($event)" (swiperight)="previousMonth()"
26-
(swipeleft)="nextMonth()">
26+
(swipeleft)="nextMonth()" (pointerdown)="suppressBlur()">
2727
<div class="igx-calendar-picker">
2828
<div tabindex="0" class="igx-calendar-picker__prev" #prevMonthBtn
2929
igxCalendarScrollMonth [startScroll]="startPrevMonthScroll" [stopScroll]="stopMonthScroll" [ngStyle]="{

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@ export class IgxCalendarComponent extends IgxMonthPickerBaseDirective implements
419419
* @internal
420420
*/
421421
private _monthsViewNumber = 1;
422-
423422
/**
424423
* @hidden
425424
* @internal
@@ -481,6 +480,11 @@ export class IgxCalendarComponent extends IgxMonthPickerBaseDirective implements
481480
this.isKeydownTrigger = isKeydownTrigger;
482481
}
483482

483+
public suppressBlur() {
484+
this.monthViews?.forEach(d => d.shouldResetDate = false);
485+
if (this.daysView) { this.daysView.shouldResetDate = false; }
486+
}
487+
484488
/**
485489
* Change to next month
486490
*
@@ -540,6 +544,9 @@ export class IgxCalendarComponent extends IgxMonthPickerBaseDirective implements
540544
} else if (this.monthScrollDirection === ScrollMonth.NEXT) {
541545
this.nextMonthBtn.nativeElement.focus();
542546
}
547+
if (event.key === KEYS.SPACE || event.key === KEYS.SPACE_IE || event.key === KEYS.ENTER) {
548+
this.resetActiveDate();
549+
}
543550

544551
this.monthScrollDirection = ScrollMonth.NONE;
545552
}
@@ -765,6 +772,7 @@ export class IgxCalendarComponent extends IgxMonthPickerBaseDirective implements
765772
public viewRendered(event) {
766773
if (event.fromState !== 'void') {
767774
this.activeViewChanged.emit(this.activeView);
775+
if (this.activeView === 0) { this.resetActiveDate(); }
768776
}
769777
}
770778

projects/igniteui-angular/src/lib/calendar/days-view/days-view.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ export class IgxDaysViewComponent extends IgxCalendarBaseDirective implements Do
119119
*/
120120
public nextMonthView: IgxDaysViewComponent;
121121

122-
/**
123-
* @hidden
124-
*/
122+
/** @hidden */
125123
public prevMonthView: IgxDaysViewComponent;
126-
public _activeDate;
127-
private shouldResetDate = true;
124+
/** @hidden */
125+
public shouldResetDate = true;
126+
private _activeDate;
127+
128128

129129
/**
130130
* The default css class applied to the component.

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
>
99
</ng-template>
1010
<ng-template #defaultCell>
11-
<div
11+
<div *ngIf="column.dataType !== 'boolean'"
1212
igxTextHighlight
1313
class="igx-grid__td-text"
1414
style="pointer-events: none;"
@@ -35,8 +35,6 @@
3535
? (value | number:column.pipeArgs.digitsInfo:grid.locale)
3636
: column.dataType === "date"
3737
? (value | date:column.pipeArgs.format:column.pipeArgs.timezone:grid.locale)
38-
: column.dataType === "boolean"
39-
? ""
4038
: value
4139
}}</div>
4240
<igx-icon

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

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { async, TestBed, fakeAsync } from '@angular/core/testing';
1+
import { async, TestBed, fakeAsync, tick } from '@angular/core/testing';
22
import { By } from '@angular/platform-browser';
33
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
44
import { IgxColumnComponent, IgxGridComponent, IgxGridModule, IGridEditEventArgs, IGridEditDoneEventArgs } from './public_api';
@@ -756,20 +756,23 @@ describe('IgxGrid - Cell Editing #grid', () => {
756756
expect(grid.cellEdit.emit).toHaveBeenCalledWith(cellArgs);
757757
});
758758

759-
it(`Should be able to cancel 'cellEdit' event`, () => {
760-
spyOn(grid.cellEdit, 'emit').and.callThrough();
759+
it(`Should be able to cancel 'cellEdit' event`, fakeAsync(() => {
760+
const emitSpy = spyOn(grid.cellEdit, 'emit').and.callThrough();
761761
grid.cellEdit.subscribe((e: IGridEditEventArgs) => {
762762
e.cancel = true;
763763
});
764-
let cell = grid.getCellByColumn(0, 'fullName');
764+
const cell = grid.getCellByColumn(0, 'fullName');
765765
let cellArgs: IGridEditEventArgs;
766766
const initialRowData = {...cell.rowData};
767767

768768
UIInteractions.simulateDoubleClickAndSelectEvent(cell);
769769
fixture.detectChanges();
770+
tick(16); // trigger igxFocus rAF
771+
const editInput = fixture.debugElement.query(By.css('igx-grid-cell input')).nativeElement;
770772

771773
expect(cell.editMode).toBe(true);
772-
let cellValue = cell.value;
774+
expect(document.activeElement).toBe(editInput);
775+
const cellValue = cell.value;
773776
const newValue = 'new value';
774777
cell.editValue = newValue;
775778

@@ -790,29 +793,39 @@ describe('IgxGrid - Cell Editing #grid', () => {
790793
expect(grid.cellEdit.emit).toHaveBeenCalledTimes(1);
791794
expect(grid.cellEdit.emit).toHaveBeenCalledWith(cellArgs);
792795

796+
emitSpy.calls.reset();
793797
UIInteractions.triggerEventHandlerKeyDown('tab', gridContent);
794798
fixture.detectChanges();
795799

796800
expect(cell.editMode).toBe(true);
797801
expect(cell.value).toBe(cellValue);
798-
expect(grid.cellEdit.emit).toHaveBeenCalledTimes(2);
802+
expect(document.activeElement).toBe(editInput);
803+
expect(grid.cellEdit.emit).toHaveBeenCalledTimes(1);
799804
expect(grid.cellEdit.emit).toHaveBeenCalledWith(cellArgs);
800805

801-
cell = grid.getCellByColumn(0, 'age');
802-
cellValue = cell.value;
803-
expect(cell.editMode).toBe(false);
806+
const nextCell = grid.getCellByColumn(0, 'age');
807+
expect(nextCell.editMode).toBe(false);
804808

805809
// activate the new cell
806-
cell.activate(null);
810+
emitSpy.calls.reset();
811+
nextCell.activate(null);
807812
fixture.detectChanges();
808-
expect(grid.cellEdit.emit).toHaveBeenCalledTimes(3);
813+
expect(grid.cellEdit.emit).toHaveBeenCalledTimes(1);
809814
expect(grid.cellEdit.emit).toHaveBeenCalledWith(cellArgs);
810815

811-
expect(cell.editMode).toBe(false);
816+
expect(nextCell.editMode).toBe(false);
817+
expect(cell.editMode).toBe(true);
818+
expect(document.activeElement).toBe(editInput);
819+
820+
emitSpy.calls.reset();
821+
UIInteractions.triggerEventHandlerKeyDown('enter', gridContent);
822+
fixture.detectChanges();
812823

813-
cell = grid.getCellByColumn(0, 'fullName');
814824
expect(cell.editMode).toBe(true);
815-
});
825+
expect(document.activeElement).toBe(editInput);
826+
expect(grid.cellEdit.emit).toHaveBeenCalledTimes(1);
827+
expect(grid.cellEdit.emit).toHaveBeenCalledWith(cellArgs);
828+
}));
816829

817830
it(`Should be able to update other cell in 'cellEdit' event`, () => {
818831
grid.primaryKey = 'personNumber';
@@ -1031,7 +1044,7 @@ describe('IgxGrid - Cell Editing #grid', () => {
10311044
expect(grid.crudService.cellInEditMode).toEqual(true);
10321045
});
10331046

1034-
it('When cellEdit is canceled the new value of the cell should never be commited nor the editing should be closed', () => {
1047+
it('When cellEdit is canceled the new value of the cell should never be committed nor the editing should be closed', () => {
10351048
const cell = grid.getCellByColumn(0, 'fullName');
10361049
grid.cellEdit.pipe(takeUntil($destroyer)).subscribe((evt) => {
10371050
evt.cancel = true;

projects/igniteui-angular/src/lib/grids/selection/selection.service.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,12 @@ export class IgxGridCRUDService {
210210
}
211211

212212
if (this.cellInEditMode) {
213+
// TODO: case solely for f2/enter nav that uses enterEditMode as toggle. Refactor.
213214
const canceled = this.grid.endEdit(true);
214-
if (this.grid.rowEditable && canceled) {
215-
this._rowEditingBlocked = canceled;
216-
}
217215

218-
this.grid.tbody.nativeElement.focus();
216+
if (!canceled || !this.cell) {
217+
this.grid.tbody.nativeElement.focus();
218+
}
219219
} else {
220220

221221
if (cell?.row.addRow) {
@@ -355,7 +355,7 @@ export class IgxGridCRUDService {
355355
}
356356

357357

358-
/** Cleares cell and row editing state and closes row editing template if it is open */
358+
/** Clears cell and row editing state and closes row editing template if it is open */
359359
public endEditMode() {
360360
this.endCellEdit();
361361
if (this.grid.rowEditable) {

projects/igniteui-angular/src/lib/grids/tree-grid/tree-cell.component.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
>
99
</ng-template>
1010
<ng-template #defaultCell>
11-
<div
11+
<div *ngIf="column.dataType !== 'boolean'"
1212
igxTextHighlight
1313
class="igx-grid__td-text"
1414
style="pointer-events: none;"
@@ -35,8 +35,6 @@
3535
? (value | number:column.pipeArgs.digitsInfo:grid.locale)
3636
: column.dataType === "date"
3737
? (value | date:column.pipeArgs.format:column.pipeArgs.timezone:grid.locale)
38-
: column.dataType === "boolean"
39-
? ""
4038
: value
4139
}}</div>
4240
<igx-icon

0 commit comments

Comments
 (0)