Skip to content

Commit

Permalink
fix(igxGrid): dirty check only checks if value exists, #2940
Browse files Browse the repository at this point in the history
  • Loading branch information
ViktorSlavov committed Nov 6, 2018
1 parent 114f9d1 commit 1a9ec68
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion projects/igniteui-angular/src/lib/grids/cell.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ export class IgxGridCellComponent implements OnInit, AfterViewInit {
if (this.grid.rowEditable) {
const rowCurrentState = this.grid.transactions.getAggregatedValue(this.row.rowID, false);
if (rowCurrentState) {
return rowCurrentState && rowCurrentState[this.column.field];
return rowCurrentState[this.column.field] !== undefined && rowCurrentState[this.column.field] !== null;
}
} else {
const rowTransaction: State = this.grid.transactions.getState(this.row.rowID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2869,6 +2869,27 @@ describe('IgxGrid Component Tests', () => {
fixture.detectChanges();
expect(cell.value).toBe('Changed product');
}));

it('Should properly mark cell/row as dirty if new value evaluates to `false`', fakeAsync(() => {
const fixture = TestBed.createComponent(IgxGridRowEditingTransactionComponent);
fixture.detectChanges();

const grid = fixture.componentInstance.grid;
const targetRow = grid.getRowByIndex(0);
let targetRowElement = targetRow.element.nativeElement;
let targetCellElement = targetRow.cells.toArray()[1].nativeElement;
expect(targetRowElement.classList).not.toContain('igx-grid__tr--edited', 'row contains edited class w/o edits');
expect(targetCellElement.classList).not.toContain('igx-grid__td--edited', 'cell contains edited class w/o edits');

targetRow.cells.toArray()[1].update('');
tick();
fixture.detectChanges();

targetRowElement = targetRow.element.nativeElement;
targetCellElement = targetRow.cells.toArray()[1].nativeElement;
expect(targetRowElement.classList).toContain('igx-grid__tr--edited', 'row does not contain edited class w/ edits');
expect(targetCellElement.classList).toContain('igx-grid__td--edited', 'cell does not contain edited class w/ edits');
}));
});

describe('Row Editing - Grouping', () => {
Expand Down

0 comments on commit 1a9ec68

Please sign in to comment.