Skip to content

Commit 8c77152

Browse files
authored
Merge branch 'master' into add--custom-sort-strategy
2 parents 132eaae + 43eeacd commit 8c77152

File tree

4 files changed

+42
-32
lines changed

4 files changed

+42
-32
lines changed

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

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -527,18 +527,16 @@ export class IgxGridCellComponent implements OnInit, AfterViewInit {
527527
return;
528528
}
529529
const editRowState = this.grid.rowEditable ? this.gridAPI.get_edit_row_state(this.gridID) : null; // Get current edited row
530-
const inEditRow = this.belongsToEditRow; // Check if cell is in current editable mode, if any
531530
this._clearCellSelection();
532531
this._saveCellSelection();
533532
const hasFilteredResults = this.grid.filteredData ? this.grid.filteredData.length > 0 : true;
534533
if (hasFilteredResults) {
535534
if (this.column.editable && this.previousCellEditMode && hasFilteredResults) {
536535
this.inEditMode = true;
537536
}
538-
if (editRowState) { // If there is a row being edited
539-
if (inEditRow && !this.column.editable) { // and this cell is in the row and is NOT editable, submit the values and close
540-
this.exitRowEdit(true, true, editRowState);
541-
}
537+
if (editRowState && !this.inEditMode) {
538+
// If there is a row being edited & this cell did not enter edit mode (!editable, row.deleted)
539+
this.exitRowEdit(true, true, editRowState);
542540
}
543541
this.selected = true;
544542
if (fireFocus) {
@@ -548,17 +546,10 @@ export class IgxGridCellComponent implements OnInit, AfterViewInit {
548546
}
549547
}
550548

551-
private get belongsToEditRow(): boolean { // If the cell belongs to the row that is currently being edited
552-
const cellInEditMode = this.gridAPI.get_cell_inEditMode(this.gridID);
553-
if (cellInEditMode && this.grid.rowEditable) {
554-
return this.cellID.rowID === cellInEditMode.cellID.rowID;
555-
}
556-
return false;
557-
}
558-
549+
/** TODO: Refactor away, move to grid.endRowEdit! */
559550
private exitRowEdit(commit = true, close = true, row?: {rowID: any, rowIndex: number}) {
560551
const grid = this.grid;
561-
if (grid.rowEditable/* && grid.rowChangesCount */) {
552+
if (grid.rowEditable) {
562553
grid.endRowTransaction(commit, close, row);
563554
}
564555
}

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,31 @@ describe('IgxGrid Component Tests', () => {
17621762
expect(gridAPI.submit_value).not.toHaveBeenCalled();
17631763
expect(gridAPI.escape_editMode).toHaveBeenCalled();
17641764
}));
1765+
1766+
it(`Should exit row editing when clicking on a cell from a deleted row`, fakeAsync(() => {
1767+
const fixture = TestBed.createComponent(IgxGridRowEditingTransactionComponent);
1768+
fixture.detectChanges();
1769+
1770+
const grid = fixture.componentInstance.grid as any;
1771+
grid.deleteRow(1);
1772+
tick();
1773+
fixture.detectChanges();
1774+
spyOn(grid, 'endRowTransaction');
1775+
1776+
const firstCell = grid.getCellByColumn(2, 'ProductName');
1777+
firstCell.inEditMode = true;
1778+
tick();
1779+
fixture.detectChanges();
1780+
expect(grid.endRowTransaction).toHaveBeenCalledTimes(0);
1781+
1782+
const targetCell = grid.getCellByColumn(0, 'ProductName');
1783+
targetCell.onFocus({});
1784+
tick();
1785+
fixture.detectChanges();
1786+
expect(grid.endRowTransaction).toHaveBeenCalledTimes(1);
1787+
expect(targetCell.focused).toBeTruthy();
1788+
expect(firstCell.focused).toBeFalsy();
1789+
}));
17651790
});
17661791

17671792
describe('Row Editing - Paging', () => {

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,7 @@ export class IgxRowComponent<T extends IgxGridBaseComponent> implements DoCheck
147147
@HostBinding('attr.aria-selected')
148148
public isSelected: boolean;
149149

150-
/**
151-
* @hidden
152-
*/
153-
@HostBinding('attr.aria-dirty')
150+
/** @hidden */
154151
public get dirty(): boolean {
155152
const row: State = this.grid.transactions.getState(this.rowID);
156153
if (row) {
@@ -160,10 +157,7 @@ export class IgxRowComponent<T extends IgxGridBaseComponent> implements DoCheck
160157
return false;
161158
}
162159

163-
/**
164-
* @hidden
165-
*/
166-
@HostBinding('attr.aria-deleted')
160+
/** @hidden */
167161
public get deleted(): boolean {
168162
const row: State = this.grid.transactions.getState(this.rowID);
169163
if (row) {

src/app/grid-row-edit/data.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const data = [{
44
SupplierID: 1,
55
CategoryID: 1,
66
QuantityPerUnit: '10 boxes x 20 bags',
7-
UnitPrice: '18.0000',
7+
UnitPrice: 18,
88
UnitsInStock: 39,
99
UnitsOnOrder: 0,
1010
ReorderLevel: 10,
@@ -16,7 +16,7 @@ export const data = [{
1616
SupplierID: 1,
1717
CategoryID: 1,
1818
QuantityPerUnit: '24 - 12 oz bottles',
19-
UnitPrice: '19.0000',
19+
UnitPrice: 19,
2020
UnitsInStock: 17,
2121
UnitsOnOrder: 40,
2222
ReorderLevel: 25,
@@ -28,7 +28,7 @@ export const data = [{
2828
SupplierID: 1,
2929
CategoryID: 2,
3030
QuantityPerUnit: '12 - 550 ml bottles',
31-
UnitPrice: '10.0000',
31+
UnitPrice: 10,
3232
UnitsInStock: 13,
3333
UnitsOnOrder: 70,
3434
ReorderLevel: 25,
@@ -40,7 +40,7 @@ export const data = [{
4040
SupplierID: 2,
4141
CategoryID: 2,
4242
QuantityPerUnit: '48 - 6 oz jars',
43-
UnitPrice: '22.0000',
43+
UnitPrice: 22,
4444
UnitsInStock: 53,
4545
UnitsOnOrder: 0,
4646
ReorderLevel: 0,
@@ -52,7 +52,7 @@ export const data = [{
5252
SupplierID: 2,
5353
CategoryID: 2,
5454
QuantityPerUnit: '36 boxes',
55-
UnitPrice: '21.3500',
55+
UnitPrice: 21.3500,
5656
UnitsInStock: 0,
5757
UnitsOnOrder: 0,
5858
ReorderLevel: 0,
@@ -64,7 +64,7 @@ export const data = [{
6464
SupplierID: 3,
6565
CategoryID: 2,
6666
QuantityPerUnit: '12 - 8 oz jars',
67-
UnitPrice: '25.0000',
67+
UnitPrice: 25,
6868
UnitsInStock: 0,
6969
UnitsOnOrder: 0,
7070
ReorderLevel: 25,
@@ -76,7 +76,7 @@ export const data = [{
7676
SupplierID: 3,
7777
CategoryID: 7,
7878
QuantityPerUnit: '12 - 1 lb pkgs.',
79-
UnitPrice: '30.0000',
79+
UnitPrice: 30,
8080
UnitsInStock: 150,
8181
UnitsOnOrder: 0,
8282
ReorderLevel: 10,
@@ -88,7 +88,7 @@ export const data = [{
8888
SupplierID: 3,
8989
CategoryID: 2,
9090
QuantityPerUnit: '12 - 12 oz jars',
91-
UnitPrice: '40.0000',
91+
UnitPrice: 40,
9292
UnitsInStock: 6,
9393
UnitsOnOrder: 0,
9494
ReorderLevel: 0,
@@ -100,7 +100,7 @@ export const data = [{
100100
SupplierID: 4,
101101
CategoryID: 6,
102102
QuantityPerUnit: '18 - 500 g pkgs.',
103-
UnitPrice: '$97.0000',
103+
UnitPrice: 97,
104104
UnitsInStock: 29,
105105
UnitsOnOrder: 0,
106106
ReorderLevel: 0,
@@ -112,7 +112,7 @@ export const data = [{
112112
SupplierID: 4,
113113
CategoryID: 8,
114114
QuantityPerUnit: '12 - 200 ml jars',
115-
UnitPrice: '31.0000',
115+
UnitPrice: 31,
116116
UnitsInStock: 31,
117117
UnitsOnOrder: 0,
118118
ReorderLevel: 0,

0 commit comments

Comments
 (0)