File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
projects/igniteui-angular/src/lib/grids/common Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -229,10 +229,13 @@ export class IgxCellCrudState {
229229 // this is needed when we are not using ngModel to update the editValue
230230 // so that the change event of the inlineEditorTemplate is hit before
231231 // trying to update any cell
232- const cellNode = this . grid . gridAPI . get_cell_by_index ( this . cell . id . rowIndex , this . cell . column . field ) . nativeElement ;
233- const document = cellNode . getRootNode ( ) as Document | ShadowRoot ;
234- const activeElement = document . activeElement as HTMLElement ;
235- activeElement . blur ( ) ;
232+ const cellNode = this . grid . gridAPI . get_cell_by_index ( this . cell . id . rowIndex , this . cell . column . field ) ?. nativeElement ;
233+ let activeElement ;
234+ if ( cellNode ) {
235+ const document = cellNode . getRootNode ( ) as Document | ShadowRoot ;
236+ activeElement = document . activeElement as HTMLElement ;
237+ activeElement . blur ( ) ;
238+ }
236239
237240 const formControl = this . grid . validation . getFormControl ( this . cell . id . rowID , this . cell . column . field ) ;
238241 if ( this . grid . validationTrigger === 'blur' && this . cell . pendingValue !== undefined ) {
@@ -260,7 +263,7 @@ export class IgxCellCrudState {
260263 const args = this . cellEdit ( event ) ;
261264 if ( args . cancel ) {
262265 // the focus is needed when we cancel the cellEdit so that the activeElement stays on the editor template
263- activeElement . focus ( ) ;
266+ activeElement ? .focus ( ) ;
264267 return args ;
265268 }
266269
You can’t perform that action at this time.
0 commit comments