Skip to content

Commit 860fcea

Browse files
MKirovaMayaKirova
authored andcommitted
fix(IgxGrid): Add checks in case cell is no longer in view.
1 parent f82a469 commit 860fcea

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,16 @@ export class IgxCellCrudState {
225225
if (!this.cell) {
226226
return;
227227
}
228+
// this is needed when we are not using ngModel to update the editValue
229+
// so that the change event of the inlineEditorTemplate is hit before
230+
// trying to update any cell
231+
const cellNode = this.grid.gridAPI.get_cell_by_index(this.cell.id.rowIndex, this.cell.column.field)?.nativeElement;
232+
let activeElement;
233+
if (cellNode) {
234+
const document = cellNode.getRootNode() as Document | ShadowRoot;
235+
activeElement = document.activeElement as HTMLElement;
236+
activeElement.blur();
237+
}
228238

229239
const formControl = this.grid.validation.getFormControl(this.cell.id.rowID, this.cell.column.field);
230240
if (this.grid.validationTrigger === 'blur' && this.cell.pendingValue !== undefined) {
@@ -251,6 +261,8 @@ export class IgxCellCrudState {
251261

252262
const args = this.cellEdit(event);
253263
if (args.cancel) {
264+
// the focus is needed when we cancel the cellEdit so that the activeElement stays on the editor template
265+
activeElement?.focus();
254266
return args;
255267
}
256268

0 commit comments

Comments
 (0)