Skip to content

Commit 1edbe34

Browse files
Merge branch 'master' into ganastasov/feat-14104-master
2 parents 552a9b1 + c227fae commit 1edbe34

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

projects/igniteui-angular/src/lib/grids/common/crud.service.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,13 @@ export class IgxCellCrudState {
254254
// this is needed when we are not using ngModel to update the editValue
255255
// so that the change event of the inlineEditorTemplate is hit before
256256
// trying to update any cell
257-
const cellNode = this.grid.gridAPI.get_cell_by_index(this.cell.id.rowIndex, this.cell.column.field).nativeElement;
258-
const document = cellNode.getRootNode() as Document | ShadowRoot;
259-
const activeElement = document.activeElement as HTMLElement;
260-
activeElement.blur();
257+
const cellNode = this.grid.gridAPI.get_cell_by_index(this.cell.id.rowIndex, this.cell.column.field)?.nativeElement;
258+
let activeElement;
259+
if (cellNode) {
260+
const document = cellNode.getRootNode() as Document | ShadowRoot;
261+
activeElement = document.activeElement as HTMLElement;
262+
activeElement.blur();
263+
}
261264

262265
const formControl = this.grid.validation.getFormControl(this.cell.id.rowID, this.cell.column.field);
263266
if (this.grid.validationTrigger === 'blur' && this.cell.pendingValue !== undefined) {
@@ -285,7 +288,7 @@ export class IgxCellCrudState {
285288
const args = this.cellEdit(event);
286289
if (args.cancel) {
287290
// the focus is needed when we cancel the cellEdit so that the activeElement stays on the editor template
288-
activeElement.focus();
291+
activeElement?.focus();
289292
return args;
290293
}
291294

0 commit comments

Comments
 (0)