Skip to content

Commit 2c6cb5f

Browse files
authored
fix(igxGrid): Add handling for outlet in case actionstrip is added po… (#16877)
1 parent b0173b1 commit 2c6cb5f

File tree

3 files changed

+85
-1
lines changed

3 files changed

+85
-1
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4096,6 +4096,13 @@ export abstract class IgxGridBaseDirective implements GridType,
40964096
this.paginationComponents.changes.pipe(takeUntil(this.destroy$)).subscribe(() => {
40974097
this.setUpPaginator();
40984098
});
4099+
4100+
this.actionStripComponents.changes.pipe(takeUntil(this.destroy$)).subscribe(() => {
4101+
if (this.actionStrip) {
4102+
this.actionStrip.menuOverlaySettings.outlet = this.outlet;
4103+
}
4104+
});
4105+
40994106
if (this.actionStrip) {
41004107
this.actionStrip.menuOverlaySettings.outlet = this.outlet;
41014108
}

projects/igniteui-angular/src/lib/grids/grid/grid-add-row.spec.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { TestBed, fakeAsync, tick, waitForAsync } from '@angular/core/testing';
44
import { DebugElement } from '@angular/core';
55
import { GridFunctions, GridSummaryFunctions } from '../../test-utils/grid-functions.spec';
66
import {
7-
IgxAddRowComponent, IgxGridRowEditingDefinedColumnsComponent, IgxGridRowEditingTransactionComponent
7+
IgxAddRowComponent, IgxGridRowEditingDefinedColumnsComponent, IgxGridRowEditingTransactionComponent,
8+
GridDynamicActionStripComponent
89
} from '../../test-utils/grid-samples.spec';
910

1011
import { By } from '@angular/platform-browser';
@@ -1119,4 +1120,32 @@ describe('IgxGrid - Row Adding #grid', () => {
11191120
expect(grid.rowChangesCount).toEqual(3);
11201121
});
11211122
});
1123+
1124+
describe('ActionStrip - Dynamic Addition', () => {
1125+
beforeEach(() => {
1126+
fixture = TestBed.createComponent(GridDynamicActionStripComponent);
1127+
fixture.detectChanges();
1128+
grid = fixture.componentInstance.grid;
1129+
});
1130+
1131+
it('Should set outlet for actionstrip menu when added post-init', async () => {
1132+
// Verify no actionstrip initially
1133+
expect(fixture.componentInstance.actionStrip).toBeUndefined();
1134+
expect(grid.actionStrip).toBeUndefined();
1135+
1136+
// Add the actionstrip dynamically
1137+
fixture.componentInstance.showActionStrip = true;
1138+
fixture.detectChanges();
1139+
await wait(16);
1140+
1141+
// Get reference to the actionstrip
1142+
actionStrip = fixture.componentInstance.actionStrip;
1143+
expect(actionStrip).toBeDefined();
1144+
expect(grid.actionStrip).toBeDefined();
1145+
1146+
// Verify that the outlet is properly set
1147+
expect(actionStrip.menuOverlaySettings.outlet).toBeDefined();
1148+
expect(actionStrip.menuOverlaySettings.outlet).toBe(grid.outlet);
1149+
});
1150+
});
11221151
});

projects/igniteui-angular/src/lib/test-utils/grid-samples.spec.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2437,6 +2437,54 @@ export class IgxAddRowComponent implements OnInit {
24372437
}
24382438
}
24392439

2440+
@Component({
2441+
template: `
2442+
<igx-grid #grid [data]="data" [width]="'800px'" [height]="'500px'"
2443+
[rowEditable]="true" [primaryKey]="'ID'">
2444+
@for (c of columns; track c.field) {
2445+
<igx-column [field]="c.field" [header]="c.field" [width]="c.width"></igx-column>
2446+
}
2447+
2448+
@if (showActionStrip) {
2449+
<igx-action-strip #actionStrip>
2450+
<igx-grid-editing-actions [addRow]='true'></igx-grid-editing-actions>
2451+
</igx-action-strip>
2452+
}
2453+
</igx-grid>
2454+
`,
2455+
imports: [
2456+
IgxGridComponent,
2457+
IgxColumnComponent,
2458+
IgxActionStripComponent,
2459+
IgxGridEditingActionsComponent
2460+
]
2461+
})
2462+
export class GridDynamicActionStripComponent implements OnInit {
2463+
@ViewChild('actionStrip', { read: IgxActionStripComponent })
2464+
public actionStrip: IgxActionStripComponent;
2465+
2466+
@ViewChild('grid', { read: IgxGridComponent, static: true })
2467+
public grid: IgxGridComponent;
2468+
2469+
public data: any[];
2470+
public columns: any[];
2471+
public showActionStrip = false;
2472+
2473+
public ngOnInit() {
2474+
this.columns = [
2475+
{ field: 'ID', width: '200px' },
2476+
{ field: 'CompanyName', width: '200px' },
2477+
{ field: 'ContactName', width: '200px' }
2478+
];
2479+
2480+
this.data = [
2481+
{ ID: 'ALFKI', CompanyName: 'Alfreds Futterkiste', ContactName: 'Maria Anders' },
2482+
{ ID: 'ANATR', CompanyName: 'Ana Trujillo Emparedados y helados', ContactName: 'Ana Trujillo' },
2483+
{ ID: 'ANTON', CompanyName: 'Antonio Moreno Taquería', ContactName: 'Antonio Moreno' }
2484+
];
2485+
}
2486+
}
2487+
24402488
@Component({
24412489
template: GridTemplateStrings.declareGrid(` [hideGroupedColumns]="true"`, '', ColumnDefinitions.exportGroupedDataColumns),
24422490
imports: [IgxGridComponent, IgxColumnComponent]

0 commit comments

Comments
 (0)