Skip to content

Commit dce187b

Browse files
authored
Merge branch 'master' into chore()-readme-update-release-notes
2 parents 37eca95 + 65f311c commit dce187b

File tree

12 files changed

+147
-9
lines changed

12 files changed

+147
-9
lines changed

projects/igniteui-angular-elements/src/app/custom-strategy.spec.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import {
1212
IgcPaginatorComponent,
1313
IgcGridStateComponent,
1414
IgcColumnLayoutComponent,
15+
IgcActionStripComponent,
16+
IgcGridEditingActionsComponent,
1517
} from './components';
1618
import { defineComponents } from '../utils/register';
1719

@@ -27,6 +29,8 @@ describe('Elements: ', () => {
2729
IgcColumnLayoutComponent,
2830
IgcPaginatorComponent,
2931
IgcGridStateComponent,
32+
IgcActionStripComponent,
33+
IgcGridEditingActionsComponent
3034
);
3135
});
3236

@@ -230,5 +234,66 @@ describe('Elements: ', () => {
230234
expect(grid.columns.length).toEqual(6);
231235
expect(grid.getColumnByVisibleIndex(1).field).toEqual('ProductName');
232236
});
237+
238+
it('should not destroy action strip when row it is shown in is destroyed or cached.', async() => {
239+
const innerHtml = `
240+
<igc-grid id="testGrid" auto-generate>
241+
<igc-action-strip id="testStrip">
242+
<igc-grid-editing-actions add-row="true"></igc-grid-editing-actions>
243+
</igc-action-strip>
244+
</igc-grid>`;
245+
testContainer.innerHTML = innerHtml;
246+
247+
// TODO: Better way to wait - potentially expose the queue or observable for update on the strategy
248+
await firstValueFrom(timer(10 /* SCHEDULE_DELAY */ * 3));
249+
250+
const grid = document.querySelector<IgcNgElement & InstanceType<typeof IgcGridComponent>>('#testGrid');
251+
const actionStrip = document.querySelector<IgcNgElement & InstanceType<typeof IgcActionStripComponent>>('#testStrip');
252+
grid.data = SampleTestData.foodProductData();
253+
254+
// TODO: Better way to wait - potentially expose the queue or observable for update on the strategy
255+
await firstValueFrom(timer(10 /* SCHEDULE_DELAY */ * 3));
256+
257+
let row = grid.dataRowList.toArray()[0];
258+
actionStrip.show(row);
259+
await firstValueFrom(timer(10 /* SCHEDULE_DELAY */ * 3));
260+
261+
expect(actionStrip.hidden).toBeFalse();
262+
263+
grid.data = [];
264+
await firstValueFrom(timer(10 /* SCHEDULE_DELAY */ * 3));
265+
266+
// row destroyed
267+
expect((row.cdr as any).destroyed).toBeTrue();
268+
// action strip still in DOM, only hidden.
269+
expect(actionStrip.hidden).toBeTrue();
270+
expect(actionStrip.isConnected).toBeTrue();
271+
272+
grid.data = SampleTestData.foodProductData();
273+
grid.groupBy({ fieldName: 'InStock', dir: 1, ignoreCase: false });
274+
275+
// TODO: Better way to wait - potentially expose the queue or observable for update on the strategy
276+
await firstValueFrom(timer(10 /* SCHEDULE_DELAY */ * 3));
277+
278+
row = grid.dataRowList.toArray()[0];
279+
actionStrip.show(row);
280+
await firstValueFrom(timer(10 /* SCHEDULE_DELAY */ * 3));
281+
282+
expect(actionStrip.hidden).toBeFalse();
283+
284+
// collapse all data rows, leave only groups
285+
grid.toggleAllGroupRows();
286+
287+
// TODO: Better way to wait - potentially expose the queue or observable for update on the strategy
288+
await firstValueFrom(timer(10 /* SCHEDULE_DELAY */ * 3));
289+
290+
// row not destroyed, but also not in dom anymore
291+
expect((row.cdr as any).destroyed).toBeFalse();
292+
expect(row.element.nativeElement.isConnected).toBe(false);
293+
294+
// action strip still in DOM, only hidden.
295+
expect(actionStrip.hidden).toBeTrue();
296+
expect(actionStrip.isConnected).toBeTrue();
297+
});
233298
});
234299
});

projects/igniteui-angular/src/lib/action-strip/grid-actions/grid-editing-actions.component.spec.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { IgxGridPinningActionsComponent } from './grid-pinning-actions.component
1515
import { IgxActionStripComponent } from '../action-strip.component';
1616
import { IRowDataCancelableEventArgs, IgxColumnComponent } from '../../grids/public_api';
1717
import { SampleTestData } from '../../test-utils/sample-test-data.spec';
18+
import { SortingDirection } from '../../data-operations/sorting-strategy';
1819

1920
describe('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', () => {

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6439,6 +6439,12 @@ export abstract class IgxGridBaseDirective implements GridType,
64396439
}
64406440
}
64416441

6442+
protected viewDetachHandler(args) {
6443+
if (this.actionStrip && args.view.rootNodes.find(x => x === this.actionStrip.context?.element.nativeElement)) {
6444+
this.actionStrip.hide();
6445+
}
6446+
}
6447+
64426448
/**
64436449
* @hidden @internal
64446450
*/

projects/igniteui-angular/src/lib/grids/grid/grid.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
[igxTemplateOutletContext]="getContext(rowData, rowIndex)"
110110
(cachedViewLoaded)="cachedViewLoaded($event)"
111111
(viewCreated)="viewCreatedHandler($event)"
112+
(beforeViewDetach)="viewDetachHandler($event)"
112113
(viewMoved)="viewMovedHandler($event)">
113114
</ng-template>
114115
</ng-template>

projects/igniteui-angular/src/lib/grids/grid/grid.component.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,17 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
13041304
super.onColumnsAddedOrRemoved();
13051305
}
13061306

1307+
/**
1308+
* @hidden
1309+
*/
1310+
protected override onColumnsChanged(change: QueryList<IgxColumnComponent>) {
1311+
super.onColumnsChanged(change);
1312+
1313+
if (this.hasColumnLayouts && !(this.navigation instanceof IgxGridMRLNavigationService)) {
1314+
this._setupNavigationService();
1315+
}
1316+
}
1317+
13071318
/**
13081319
* @hidden @internal
13091320
*/

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
<ng-template
8686
[igxTemplateOutlet]="(isHierarchicalRecord(rowData) ? hierarchical_record_template : (isChildGridRecord(rowData) ? child_record_template : hierarchical_record_template))"
8787
[igxTemplateOutletContext]="getContext(rowData, rowIndex, false)" (viewCreated)="viewCreatedHandler($event)"
88-
(viewMoved)="viewMovedHandler($event)" (cachedViewLoaded)="cachedViewLoaded($event)">
88+
(viewMoved)="viewMovedHandler($event)" (cachedViewLoaded)="cachedViewLoaded($event)" (beforeViewDetach)="viewDetachHandler($event)">
8989
</ng-template>
9090
<!-- <ng-container *igxTemplateOutlet="(isHierarchicalRecord(rowData) ? hierarchical_record_template : (isChildGridRecord(rowData) && isExpanded(rowData) ? child_record_template : hierarchical_record_template)); context: getContext(rowData)"></ng-container> -->
9191
</ng-template>

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2022,7 +2022,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
20222022
}
20232023

20242024
protected getPivotRowHeaderContentWidth(headerGroup: IgxPivotRowHeaderGroupComponent) {
2025-
const headerSizes = this.getHeaderCellWidth(headerGroup.header.refInstance.nativeElement);
2025+
const headerSizes = this.getHeaderCellWidth(headerGroup.nativeElement);
20262026
return headerSizes.width + headerSizes.padding;
20272027
}
20282028

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-header-row.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@
254254
<igx-pivot-row-header-group #rowDimensionHeaders
255255
[ngClass]="dimCol.headerGroupClasses"
256256
[ngStyle]="dimCol.headerGroupStyles | igxHeaderGroupStyle:dimCol:grid.pipeTrigger"
257-
[style.min-width]="grid.rowDimensionWidthToPixels(this.grid.visibleRowDimensions[colIndex])"
258-
[style.flex-basis]="grid.rowDimensionWidthToPixels(this.grid.visibleRowDimensions[colIndex])"
257+
[style.width.px]="grid.rowDimensionWidthToPixels(this.grid.visibleRowDimensions[colIndex])"
258+
[style.flex-basis.px]="grid.rowDimensionWidthToPixels(this.grid.visibleRowDimensions[colIndex])"
259259
[column]="dimCol"
260260
[rootDimension]="grid.visibleRowDimensions[colIndex]"
261261
[dimWidth]="grid.rowDimensionWidthToPixels(this.grid.visibleRowDimensions[colIndex])"

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-row-dimension-header-group.component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
(keydown)="grid.navigation.headerNavigation($event)"
2929
[style.min-width]="getHeaderWidthFromDimension()"
3030
[style.width]="getHeaderWidthFromDimension()"
31-
[style.flex-basis]="getHeaderWidthFromDimension()"
3231
>
3332
</igx-pivot-row-dimension-header>
3433
@if (!column.columnGroup && column.resizable) {

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-row-header-group.component.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,6 @@ export class IgxPivotRowHeaderGroupComponent extends IgxGridHeaderGroupComponent
159159
}
160160

161161
protected getHeaderWidthFromDimension() {
162-
if (this.grid.hasHorizontalLayout) {
163-
return this.dimWidth === -1 ? 'fit-content' : this.width;
164-
}
165-
return this.grid.rowDimensionWidth(this.parent.rootDimension);
162+
return this.grid.hasHorizontalLayout && this.dimWidth === -1 ? 'fit-content' : null;
166163
}
167164
}

0 commit comments

Comments
 (0)