@@ -11,6 +11,9 @@ import {
1111 IgcColumnComponent ,
1212 IgcPaginatorComponent ,
1313 IgcGridStateComponent ,
14+ IgcColumnLayoutComponent ,
15+ IgcActionStripComponent ,
16+ IgcGridEditingActionsComponent ,
1417} from './components' ;
1518import { defineComponents } from '../utils/register' ;
1619
@@ -25,6 +28,8 @@ describe('Elements: ', () => {
2528 IgcColumnComponent ,
2629 IgcPaginatorComponent ,
2730 IgcGridStateComponent ,
31+ IgcActionStripComponent ,
32+ IgcGridEditingActionsComponent
2833 ) ;
2934 } ) ;
3035
@@ -181,5 +186,66 @@ describe('Elements: ', () => {
181186 await firstValueFrom ( timer ( 10 /* SCHEDULE_DELAY */ * 2 ) ) ;
182187 expect ( ( ) => stateComponent . getStateAsString ( ) ) . not . toThrow ( ) ;
183188 } ) ;
189+
190+ it ( 'should not destroy action strip when row it is shown in is destroyed or cached.' , async ( ) => {
191+ const innerHtml = `
192+ <igc-grid id="testGrid" auto-generate>
193+ <igc-action-strip id="testStrip">
194+ <igc-grid-editing-actions add-row="true"></igc-grid-editing-actions>
195+ </igc-action-strip>
196+ </igc-grid>` ;
197+ testContainer . innerHTML = innerHtml ;
198+
199+ // TODO: Better way to wait - potentially expose the queue or observable for update on the strategy
200+ await firstValueFrom ( timer ( 10 /* SCHEDULE_DELAY */ * 3 ) ) ;
201+
202+ const grid = document . querySelector < IgcNgElement & InstanceType < typeof IgcGridComponent > > ( '#testGrid' ) ;
203+ const actionStrip = document . querySelector < IgcNgElement & InstanceType < typeof IgcActionStripComponent > > ( '#testStrip' ) ;
204+ grid . data = SampleTestData . foodProductData ( ) ;
205+
206+ // TODO: Better way to wait - potentially expose the queue or observable for update on the strategy
207+ await firstValueFrom ( timer ( 10 /* SCHEDULE_DELAY */ * 3 ) ) ;
208+
209+ let row = grid . dataRowList . toArray ( ) [ 0 ] ;
210+ actionStrip . show ( row ) ;
211+ await firstValueFrom ( timer ( 10 /* SCHEDULE_DELAY */ * 3 ) ) ;
212+
213+ expect ( actionStrip . hidden ) . toBeFalse ( ) ;
214+
215+ grid . data = [ ] ;
216+ await firstValueFrom ( timer ( 10 /* SCHEDULE_DELAY */ * 3 ) ) ;
217+
218+ // row destroyed
219+ expect ( ( row . cdr as any ) . destroyed ) . toBeTrue ( ) ;
220+ // action strip still in DOM, only hidden.
221+ expect ( actionStrip . hidden ) . toBeTrue ( ) ;
222+ expect ( actionStrip . isConnected ) . toBeTrue ( ) ;
223+
224+ grid . data = SampleTestData . foodProductData ( ) ;
225+ grid . groupBy ( { fieldName : 'InStock' , dir : 1 , ignoreCase : false } ) ;
226+
227+ // TODO: Better way to wait - potentially expose the queue or observable for update on the strategy
228+ await firstValueFrom ( timer ( 10 /* SCHEDULE_DELAY */ * 3 ) ) ;
229+
230+ row = grid . dataRowList . toArray ( ) [ 0 ] ;
231+ actionStrip . show ( row ) ;
232+ await firstValueFrom ( timer ( 10 /* SCHEDULE_DELAY */ * 3 ) ) ;
233+
234+ expect ( actionStrip . hidden ) . toBeFalse ( ) ;
235+
236+ // collapse all data rows, leave only groups
237+ grid . toggleAllGroupRows ( ) ;
238+
239+ // TODO: Better way to wait - potentially expose the queue or observable for update on the strategy
240+ await firstValueFrom ( timer ( 10 /* SCHEDULE_DELAY */ * 3 ) ) ;
241+
242+ // row not destroyed, but also not in dom anymore
243+ expect ( ( row . cdr as any ) . destroyed ) . toBeFalse ( ) ;
244+ expect ( row . element . nativeElement . isConnected ) . toBe ( false ) ;
245+
246+ // action strip still in DOM, only hidden.
247+ expect ( actionStrip . hidden ) . toBeTrue ( ) ;
248+ expect ( actionStrip . isConnected ) . toBeTrue ( ) ;
249+ } ) ;
184250 } ) ;
185251} ) ;
0 commit comments