Skip to content

Commit deecdad

Browse files
authored
Merge branch '7.3.x' into fix-#4859
2 parents 1cdd8a0 + 751a94a commit deecdad

File tree

4 files changed

+41
-4
lines changed

4 files changed

+41
-4
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ export class IgxDialogComponent implements IToggleView, OnInit, OnDestroy, After
259259
public onRightButtonSelect = new EventEmitter<IDialogEventArgs>();
260260

261261
private _animaitonSettings: PositionSettings = {
262-
openAnimation: useAnimation(slideInBottom, {params: {fromPosition: 'translateY(100%)'}}),
263-
closeAnimation: useAnimation(slideOutTop, {params: {toPosition: 'translateY(-100%)'}})
262+
openAnimation: useAnimation(slideInBottom, { params: { fromPosition: 'translateY(100%)' } }),
263+
closeAnimation: useAnimation(slideOutTop, { params: { toPosition: 'translateY(-100%)' } })
264264
};
265265

266266
private _overlayDefaultSettings: OverlaySettings;
@@ -391,6 +391,9 @@ export class IgxDialogComponent implements IToggleView, OnInit, OnDestroy, After
391391
public open(overlaySettings: OverlaySettings = this._overlayDefaultSettings) {
392392
this.toggleRef.open(overlaySettings);
393393
this.onOpen.emit({ dialog: this, event: null });
394+
if (!this.leftButtonLabel && !this.rightButtonLabel) {
395+
this.toggleRef.element.focus();
396+
}
394397
}
395398

396399
/**

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,11 +591,14 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
591591
/**
592592
* Sets whether rows can be edited.
593593
* ```html
594-
* <igx-grid #grid [showToolbar]="true" [rowEditable]="true" [columnHiding]="true"></igx-grid>
594+
* <igx-grid #grid [showToolbar]="true" [rowEditable]="true" [primaryKey]="'ProductID'" [columnHiding]="true"></igx-grid>
595595
* ```
596596
* @memberof IgxGridBaseComponent
597597
*/
598598
set rowEditable(val: boolean) {
599+
if (val && (this.primaryKey === undefined || this.primaryKey === null)) {
600+
console.warn('The grid must have a `primaryKey` specified when using `rowEditable`!');
601+
}
599602
this._rowEditable = val;
600603
if (this.gridAPI.grid) {
601604
this.refreshGridState();

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,6 +1342,36 @@ describe('IgxGrid Component Tests', () => {
13421342
}));
13431343

13441344
describe('Row Editing - General tests', () => {
1345+
it('Should throw a warning when [rowEditable] is set on a grid w/o [primaryKey]', fakeAsync(() => {
1346+
const fix = TestBed.createComponent(IgxGridRowEditingComponent);
1347+
fix.detectChanges();
1348+
const grid = fix.componentInstance.grid;
1349+
grid.primaryKey = null;
1350+
grid.rowEditable = false;
1351+
tick();
1352+
fix.detectChanges();
1353+
1354+
spyOn(console, 'warn');
1355+
grid.rowEditable = true;
1356+
tick();
1357+
fix.detectChanges();
1358+
expect(console.warn).toHaveBeenCalledWith('The grid must have a `primaryKey` specified when using `rowEditable`!');
1359+
expect(console.warn).toHaveBeenCalledTimes(1);
1360+
// Throws warinig but still sets the property correctly
1361+
expect(grid.rowEditable).toBeTruthy();
1362+
1363+
tick();
1364+
fix.detectChanges();
1365+
grid.primaryKey = 'ProductID';
1366+
grid.rowEditable = false;
1367+
tick();
1368+
fix.detectChanges();
1369+
grid.rowEditable = true;
1370+
tick();
1371+
fix.detectChanges();
1372+
expect(console.warn).toHaveBeenCalledTimes(1);
1373+
expect(grid.rowEditable).toBeTruthy();
1374+
}));
13451375
it('Should be able to enter edit mode on dblclick, enter and f2', fakeAsync(() => {
13461376
const fix = TestBed.createComponent(IgxGridRowEditingComponent);
13471377
fix.detectChanges();

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,7 @@ describe('IgxGrid - Row Drag Tests', () => {
863863
<igx-grid #grid
864864
[width]='width'
865865
[height]='height'
866+
primaryKey="ID"
866867
[data]="data"
867868
[autoGenerate]="true" (onColumnInit)="columnsCreated($event)" (onGroupingDone)="onGroupingDoneHandler($event)"
868869
[rowEditable]="true" [rowDraggable]="enableRowDraggable"
@@ -916,7 +917,7 @@ export class IgxGridRowDraggableComponent extends DataParent {
916917
[width]="'800px'"
917918
[height]="'300px'"
918919
[data]="data"
919-
[primaryKey]="'ID'"
920+
primaryKey="ID"
920921
[autoGenerate]="true" (onGroupingDone)="onGroupingDoneHandler($event)"
921922
[rowEditable]="true" [rowDraggable]="true"
922923
>

0 commit comments

Comments
 (0)