@@ -15,6 +15,7 @@ import { IgxGridPinningActionsComponent } from './grid-pinning-actions.component
1515import { IgxActionStripComponent } from '../action-strip.component' ;
1616import { IRowDataCancelableEventArgs , IgxColumnComponent } from '../../grids/public_api' ;
1717import { SampleTestData } from '../../test-utils/sample-test-data.spec' ;
18+ import { SortingDirection } from '../../data-operations/sorting-strategy' ;
1819
1920describe ( 'igxGridEditingActions #grid ' , ( ) => {
2021 let fixture ;
@@ -274,6 +275,59 @@ describe('igxGridEditingActions #grid ', () => {
274275
275276 expect ( actionStrip . hidden ) . toBeTrue ( ) ;
276277 } ) ;
278+
279+ it ( 'should auto-hide on delete action click.' , ( ) => {
280+ const row = grid . rowList . toArray ( ) [ 0 ] ;
281+ actionStrip . show ( row ) ;
282+ fixture . detectChanges ( ) ;
283+
284+ expect ( actionStrip . hidden ) . toBeFalse ( ) ;
285+
286+ const deleteIcon = fixture . debugElement . queryAll ( By . css ( `igx-grid-editing-actions igx-icon` ) ) [ 1 ] ;
287+ expect ( deleteIcon . nativeElement . innerText ) . toBe ( 'delete' ) ;
288+ deleteIcon . parent . triggerEventHandler ( 'click' , new Event ( 'click' ) ) ;
289+ fixture . detectChanges ( ) ;
290+
291+ expect ( actionStrip . hidden ) . toBeTrue ( ) ;
292+
293+ } ) ;
294+
295+ it ( 'should auto-hide if context row is destroyed.' , ( ) => {
296+ const row = grid . rowList . toArray ( ) [ 0 ] ;
297+ actionStrip . show ( row ) ;
298+ fixture . detectChanges ( ) ;
299+
300+ expect ( actionStrip . hidden ) . toBeFalse ( ) ;
301+
302+ // bind to no data, which removes all rows.
303+ grid . data = [ ] ;
304+ grid . cdr . detectChanges ( ) ;
305+
306+ expect ( ( row . cdr as any ) . destroyed ) . toBeTrue ( ) ;
307+ expect ( actionStrip . hidden ) . toBeTrue ( ) ;
308+ } ) ;
309+
310+ it ( 'should auto-hide if context row is cached.' , ( ) => {
311+ // create group rows
312+ grid . groupBy ( { fieldName : 'ContactTitle' , dir : SortingDirection . Desc , ignoreCase : false } ) ;
313+ fixture . detectChanges ( ) ;
314+
315+ // show for first data row
316+ const row = grid . dataRowList . toArray ( ) [ 0 ] ;
317+ actionStrip . show ( row ) ;
318+ fixture . detectChanges ( ) ;
319+
320+ // collapse all groups to cache data rows
321+ grid . toggleAllGroupRows ( ) ;
322+ fixture . detectChanges ( ) ;
323+
324+ // not destroyed, but not in DOM anymore
325+ expect ( ( row . cdr as any ) . destroyed ) . toBeFalse ( ) ;
326+ expect ( row . element . nativeElement . isConnected ) . toBe ( false ) ;
327+
328+ // action strip should be hidden
329+ expect ( actionStrip . hidden ) . toBeTrue ( ) ;
330+ } ) ;
277331 } ) ;
278332
279333 describe ( 'auto show/hide in HierarchicalGrid' , ( ) => {
0 commit comments