@@ -9,11 +9,12 @@ import { GridFunctions } from '../../test-utils/grid-functions.spec';
9
9
import {
10
10
CellEditingTestComponent , CellEditingScrollTestComponent ,
11
11
SelectionWithTransactionsComponent ,
12
- ColumnEditablePropertyTestComponent
12
+ ColumnEditablePropertyTestComponent ,
13
+ CellEditingCustomEditorTestComponent
13
14
} from '../../test-utils/grid-samples.spec' ;
14
15
import { DebugElement } from '@angular/core' ;
15
- import { takeUntil } from 'rxjs/operators' ;
16
- import { Subject } from 'rxjs' ;
16
+ import { first , takeUntil } from 'rxjs/operators' ;
17
+ import { Subject , fromEvent } from 'rxjs' ;
17
18
import { SortingDirection } from '../../data-operations/sorting-strategy' ;
18
19
import { IGridEditDoneEventArgs , IGridEditEventArgs , IgxColumnComponent } from '../public_api' ;
19
20
@@ -328,6 +329,38 @@ describe('IgxGrid - Cell Editing #grid', () => {
328
329
expect ( ( document . activeElement as HTMLInputElement ) . selectionStart ) . toEqual ( 0 )
329
330
expect ( ( document . activeElement as HTMLInputElement ) . selectionEnd ) . toEqual ( 10 )
330
331
} ) ) ;
332
+
333
+ it ( 'should work correct when not using ngModel but value and change event' , fakeAsync ( ( ) => {
334
+ fixture = TestBed . createComponent ( CellEditingCustomEditorTestComponent ) ;
335
+ fixture . detectChanges ( ) ;
336
+ grid = fixture . componentInstance . grid ;
337
+ gridContent = GridFunctions . getGridContent ( fixture ) ;
338
+ grid . getColumnByName ( "fullName" ) . inlineEditorTemplate = fixture . componentInstance . templateCell ;
339
+ fixture . detectChanges ( ) ;
340
+
341
+ const cell = grid . gridAPI . get_cell_by_index ( 0 , 'fullName' ) ;
342
+
343
+ UIInteractions . simulateDoubleClickAndSelectEvent ( cell ) ;
344
+ fixture . detectChanges ( ) ;
345
+ tick ( 16 ) ; // trigger igxFocus
346
+
347
+ expect ( cell . editMode ) . toBe ( true ) ;
348
+ const newValue = 'new value' ;
349
+
350
+ const editTemplate = fixture . debugElement . query ( By . css ( 'input' ) ) ;
351
+ fromEvent ( editTemplate . nativeElement , "blur" ) . pipe ( first ( ) ) . subscribe ( ( ) => {
352
+ // needed because we cannot simulate entirely user input (change event needs it)
353
+ editTemplate . nativeElement . dispatchEvent ( new Event ( 'change' ) ) ;
354
+ fixture . detectChanges ( ) ;
355
+ } ) ;
356
+ UIInteractions . clickAndSendInputElementValue ( editTemplate , newValue ) ;
357
+ fixture . detectChanges ( ) ;
358
+
359
+ UIInteractions . triggerEventHandlerKeyDown ( 'enter' , gridContent ) ;
360
+ fixture . detectChanges ( ) ;
361
+ expect ( cell . editMode ) . toBe ( false ) ;
362
+ expect ( cell . value ) . toBe ( newValue ) ;
363
+ } ) ) ;
331
364
} ) ;
332
365
333
366
describe ( 'Scroll, pin and blur' , ( ) => {
0 commit comments