Skip to content

Commit f45736b

Browse files
authored
Merge pull request #6807 from IgniteUI/vmihalkov/column-moving-fix
Column moving with right pinning
2 parents c631ee8 + 3d43201 commit f45736b

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3605,8 +3605,14 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
36053605

36063606
if (dropTarget.pinned && !column.pinned) {
36073607
column.pin();
3608+
if (!this.isPinningToStart) {
3609+
if (pos === DropPosition.AfterDropTarget) {
3610+
position = DropPosition.AfterDropTarget;
3611+
} else {
3612+
position = DropPosition.None;
3613+
}
3614+
}
36083615
this._reorderColumns(column, dropTarget, position, this._pinnedColumns);
3609-
36103616
}
36113617

36123618
if (!dropTarget.pinned && column.pinned) {

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,28 @@ describe('IgxGrid - Column Pinning #grid', () => {
574574
expect(fistPinnedHeaders[1].context.column.field).toBe('CompanyName');
575575
});
576576

577+
it('should pin an unpinned column when drag/drop it among pinned columns.', (async() => {
578+
579+
const fix = TestBed.createComponent(GridRightPinningComponent);
580+
fix.detectChanges();
581+
582+
const grid = fix.componentInstance.instance;
583+
grid.pinning = { columns: ColumnPinningPosition.End };
584+
fix.detectChanges();
585+
await wait();
586+
fix.detectChanges();
587+
588+
// move 'ID' column to the pinned area
589+
grid.moveColumn(grid.getColumnByName('ID'), grid.getColumnByName('ContactName'));
590+
fix.detectChanges();
591+
592+
// verify column is pinned at the correct place
593+
expect(grid.pinnedColumns[0].field).toEqual('CompanyName');
594+
expect(grid.pinnedColumns[1].field).toEqual('ID');
595+
expect(grid.pinnedColumns[2].field).toEqual('ContactName');
596+
expect(grid.getColumnByName('ID').pinned).toBeTruthy();
597+
}));
598+
577599
it('should correctly pin columns with their summaries to end.', async() => {
578600
const fix = TestBed.createComponent(GridRightPinningComponent);
579601
fix.detectChanges();

0 commit comments

Comments
 (0)