@@ -694,6 +694,44 @@ describe('IgxGrid - Cell Editing #grid', () => {
694694 expect ( cell . value ) . toEqual ( 'New Name' ) ;
695695 } ) ;
696696
697+ it ( `Should not update data in grid with transactions, when row is updated in onCellEdit and onCellEdit is canceled` , ( ) => {
698+ fixture = TestBed . createComponent ( SelectionWithTransactionsComponent ) ;
699+ fixture . detectChanges ( ) ;
700+ grid = fixture . componentInstance . grid ;
701+
702+ grid . primaryKey = 'ID' ;
703+ fixture . detectChanges ( ) ;
704+
705+ // update the cell value via updateRow and cancel the event
706+ grid . onCellEdit . subscribe ( ( e : IGridEditEventArgs ) => {
707+ const rowIndex : number = e . cellID . rowIndex ;
708+ const row = grid . getRowByIndex ( rowIndex ) ;
709+ grid . updateRow ( { [ row . columns [ e . cellID . columnID ] . field ] : e . newValue } , row . rowID ) ;
710+ e . cancel = true ;
711+ } ) ;
712+
713+ const cell = grid . getCellByColumn ( 0 , 'Name' ) ;
714+ const initialValue = cell . value ;
715+ const firstNewValue = 'New Value' ;
716+ const secondNewValue = 'Very New Value' ;
717+
718+ cell . update ( firstNewValue ) ;
719+ fixture . detectChanges ( ) ;
720+ expect ( cell . value ) . toBe ( firstNewValue ) ;
721+
722+ cell . update ( secondNewValue ) ;
723+ fixture . detectChanges ( ) ;
724+ expect ( cell . value ) . toBe ( secondNewValue ) ;
725+
726+ grid . transactions . undo ( ) ;
727+ fixture . detectChanges ( ) ;
728+ expect ( cell . value ) . toBe ( firstNewValue ) ;
729+
730+ grid . transactions . undo ( ) ;
731+ fixture . detectChanges ( ) ;
732+ expect ( cell . value ) . toBe ( initialValue ) ;
733+ } ) ;
734+
697735 it ( `Should properly emit 'onCellEditCancel' event` , ( ) => {
698736 spyOn ( grid . onCellEditCancel , 'emit' ) . and . callThrough ( ) ;
699737 const cell = grid . getCellByColumn ( 0 , 'fullName' ) ;
0 commit comments