Skip to content

Commit

Permalink
Merge pull request #3477 from IgniteUI/ddincheva/cellFocus-master
Browse files Browse the repository at this point in the history
Focus the default inputs when cell enter edit mode
  • Loading branch information
zdrawku authored Jan 3, 2019
2 parents 35e0d01 + 16b04b3 commit 94f5920
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 7 additions & 2 deletions projects/igniteui-angular/src/lib/grids/cell.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ export class IgxGridCellComponent implements OnInit, AfterViewInit {
return;
}
if (this.column.editable && value) {
this.focused = true;
this.gridAPI.set_cell_inEditMode(this.gridID, this);
if (this.highlight && this.grid.lastSearchInfo.searchText) {
this.highlight.observe();
Expand Down Expand Up @@ -522,6 +523,10 @@ export class IgxGridCellComponent implements OnInit, AfterViewInit {
this.selected = true;
if (fireFocus) {
this.nativeElement.focus();
} else {
if (!this.focused) {
this.focused = this.nativeElement === document.activeElement;
}
}
this.grid.onSelection.emit({ cell: this, event });
}
Expand Down Expand Up @@ -826,8 +831,8 @@ export class IgxGridCellComponent implements OnInit, AfterViewInit {
}

public onKeydownExitEditMode(event) {
if (this.column.editable) {
const editableCell = this.gridAPI.get_cell_inEditMode(this.gridID);
const editableCell = this.gridAPI.get_cell_inEditMode(this.gridID);
if (this.column.editable && editableCell) {
const args: IGridEditEventArgs = {
cellID: editableCell.cellID,
rowID: editableCell.cellID.rowID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1794,11 +1794,12 @@ describe('IgxGrid Component Tests', () => {

const targetCell = grid.getCellByColumn(0, 'ProductName');
targetCell.onFocus({});
tick();
tick(100);
fixture.detectChanges();
expect(grid.endRowTransaction).toHaveBeenCalledTimes(1);
expect(targetCell.focused).toBeTruthy();
expect(firstCell.focused).toBeFalsy();
expect(targetCell.selected).toBeTruthy();
expect(firstCell.selected).toBeFalsy();
}));
});

Expand Down

0 comments on commit 94f5920

Please sign in to comment.