Skip to content

Commit 5ade2b5

Browse files
authored
Merge branch '9.1.x' into ibarakov/fix-8466-9.1.x
2 parents f836ffd + dbc962b commit 5ade2b5

File tree

8 files changed

+78
-20
lines changed

8 files changed

+78
-20
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
789789
const dragMode = this.selectionService.pointerEnter(this.selectionNode, event);
790790
if (dragMode) {
791791
this.grid.cdr.detectChanges();
792+
if (isIE()) { this.grid.tbody.nativeElement.focus({ preventScroll: true }); }
792793
}
793794
}
794795

@@ -802,6 +803,7 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
802803
this.grid.navigation.activeNode.gridID !== this.gridID))) { return; }
803804
if (this.selectionService.pointerUp(this.selectionNode, this.grid.onRangeSelection)) {
804805
this.grid.cdr.detectChanges();
806+
if (isIE()) { this.grid.tbody.nativeElement.focus({ preventScroll: true }); }
805807
}
806808
this._updateCRUDStatus();
807809
}

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

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2847,6 +2847,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
28472847
_setupListeners() {
28482848
const destructor = takeUntil<any>(this.destroy$);
28492849
fromEvent(this.nativeElement, 'focusout').pipe(filter(() => !!this.navigation.activeNode), destructor).subscribe((event) => {
2850+
if (this.selectionService.dragMode && isIE()) { return; }
28502851
if (!this.crudService.cell && !!this.navigation.activeNode && (event.target === this.tbody.nativeElement &&
28512852
this.navigation.activeNode.row >= 0 && this.navigation.activeNode.row < this.dataView.length)
28522853
|| (event.target === this.theadRow.nativeElement && this.navigation.activeNode.row === -1)
@@ -4933,14 +4934,14 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
49334934
let added = false;
49344935
let removed = false;
49354936

4936-
this.initColumns(this.columnList);
4937-
4938-
49394937
diff.forEachAddedItem((record: IterableChangeRecord<IgxColumnComponent>) => {
49404938
this.onColumnInit.emit(record.item);
49414939
added = true;
4940+
record.item.pinned ? this._pinnedColumns.push(record.item) : this._unpinnedColumns.push(record.item);
49424941
});
49434942

4943+
this.initColumns(this.columnList);
4944+
49444945
diff.forEachRemovedItem((record: IterableChangeRecord<IgxColumnComponent | IgxColumnGroupComponent>) => {
49454946
const isColumnGroup = record.item instanceof IgxColumnGroupComponent;
49464947
if (!isColumnGroup) {
@@ -5677,21 +5678,12 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
56775678
}
56785679
}
56795680

5680-
/**
5681-
* @hidden @internal
5682-
*/
5683-
copyHandlerIE() {
5684-
if (isIE()) {
5685-
this.copyHandler(null, true);
5686-
}
5687-
}
5688-
56895681
/**
56905682
* @hidden
56915683
* @internal
56925684
*/
5693-
public copyHandler(event, ie11 = false) {
5694-
if (!this.clipboardOptions.enabled || this.crudService.inEditMode) {
5685+
public copyHandler(event) {
5686+
if (!this.clipboardOptions.enabled || this.crudService.inEditMode || (!isIE() && event.type === 'keydown')) {
56955687
return;
56965688
}
56975689

@@ -5710,7 +5702,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
57105702
result = result.substring(result.indexOf('\n') + 1);
57115703
}
57125704

5713-
if (ie11) {
5705+
if (isIE()) {
57145706
(window as any).clipboardData.setData('Text', result);
57155707
return;
57165708
}

projects/igniteui-angular/src/lib/grids/grid-navigation.service.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ export class IgxGridNavigationService {
7575
event.preventDefault();
7676
key === 'pagedown' ? this.grid.verticalScrollContainer.scrollNextPage() :
7777
this.grid.verticalScrollContainer.scrollPrevPage();
78+
const editCell = this.grid.crudService.cell;
79+
this.grid.verticalScrollContainer.onChunkLoad
80+
.pipe(first()).subscribe(() => {
81+
if (editCell && this.grid.rowList.map(r => r.index).indexOf(editCell.rowIndex) < 0) {
82+
this.grid.tbody.nativeElement.focus({preventScroll: true});
83+
}
84+
});
7885
break;
7986
case 'tab':
8087
this.handleEditing(shift, event);

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

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { IgxGridComponent } from './grid.component';
55
import { IgxGridModule } from './public_api';
66
import { GridTemplateStrings, ColumnDefinitions } from '../../test-utils/template-strings.spec';
77
import { SampleTestData } from '../../test-utils/sample-test-data.spec';
8-
import { ColumnHiddenFromMarkupComponent, ColumnCellFormatterComponent, DynamicColumnsComponent } from '../../test-utils/grid-samples.spec';
8+
import { ColumnHiddenFromMarkupComponent, ColumnCellFormatterComponent,
9+
DynamicColumnsComponent, GridAddColumnComponent } from '../../test-utils/grid-samples.spec';
910
import { configureTestSuite } from '../../test-utils/configure-suite';
1011
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
1112
import { IgxStringFilteringOperand } from '../../data-operations/filtering-condition';
@@ -27,7 +28,8 @@ describe('IgxGrid - Column properties #grid', () => {
2728
ColumnCellFormatterComponent,
2829
ColumnHaederClassesComponent,
2930
ColumnHiddenFromMarkupComponent,
30-
DynamicColumnsComponent
31+
DynamicColumnsComponent,
32+
GridAddColumnComponent
3133
],
3234
imports: [IgxGridModule, NoopAnimationsModule]
3335
})
@@ -167,6 +169,34 @@ describe('IgxGrid - Column properties #grid', () => {
167169
expect(grid.columnList.last.field).toMatch('Name');
168170
}));
169171

172+
it('should add new column at the correct visible index', fakeAsync(() => {
173+
const fix = TestBed.createComponent(GridAddColumnComponent);
174+
fix.detectChanges();
175+
const grid = fix.componentInstance.grid;
176+
const maxVindex = fix.componentInstance.columns.length - 1;
177+
178+
// add to unpinned area
179+
fix.componentInstance.columns.push({ field: 'City', width: 150, movable: true, type: 'string' });
180+
fix.detectChanges();
181+
182+
let cityCol = grid.getColumnByName('City');
183+
expect(cityCol.visibleIndex).toEqual(maxVindex + 1);
184+
185+
// remove the newly added column
186+
fix.componentInstance.columns.pop();
187+
fix.detectChanges();
188+
189+
cityCol = grid.getColumnByName('City');
190+
expect(cityCol).not.toBeDefined();
191+
192+
// add to pinned area
193+
fix.componentInstance.columns.push({ field: 'City', width: 150, movable: true, type: 'string', pinned: true });
194+
fix.detectChanges();
195+
196+
cityCol = grid.getColumnByName('City');
197+
expect(cityCol.visibleIndex).toEqual( 1);
198+
}));
199+
170200
it('should apply columnWidth on columns that don\'t have explicit width', () => {
171201
const fix = TestBed.createComponent(ColumnCellFormatterComponent);
172202
fix.componentInstance.grid.columnWidth = '200px';

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
<div class="igx-grid__thead-thumb" [hidden]='!hasVerticalScroll()' [style.width.px]="scrollSize"></div>
9999
</div>
100100

101-
<div igxGridBody (keydown.control.c)="copyHandlerIE()" (copy)="copyHandler($event)" class="igx-grid__tbody">
101+
<div igxGridBody (keydown.control.c)="copyHandler($event)" (copy)="copyHandler($event)" class="igx-grid__tbody">
102102
<div class="igx-grid__tbody-content" tabindex="0" [attr.aria-activedescendant]="activeDescendant" (keydown)="navigation.handleNavigation($event)" (focus)="navigation.focusTbody($event)"
103103
role="rowgroup" (onDragStop)="selectionService.dragMode = $event" (scroll)='preventContainerScroll($event)'
104104
(onDragScroll)="dragScroll($event)" [igxGridDragSelect]="selectionService.dragMode"

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
@@ -82,7 +82,7 @@
8282
<div class="igx-grid__thead-thumb" [hidden]='!hasVerticalScroll()' [style.width.px]="scrollSize"></div>
8383
</div>
8484

85-
<div igxGridBody (keydown.control.c)="copyHandlerIE()" (copy)="copyHandler($event)" class="igx-grid__tbody">
85+
<div igxGridBody (keydown.control.c)="copyHandler($event)" (copy)="copyHandler($event)" class="igx-grid__tbody">
8686
<div class="igx-grid__tbody-content" tabindex="0" (focus)="navigation.focusTbody($event)" [attr.aria-activedescendant]="activeDescendant"
8787
(keydown)="navigation.handleNavigation($event)" (onDragStop)="selectionService.dragMode = $event"
8888
(onDragScroll)="dragScroll($event)" [igxGridDragSelect]="selectionService.dragMode" role="rowgroup"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
id="right" class="igx-grid__scroll-on-drag-right"></span>
6565
</div>
6666

67-
<div igxGridBody (keydown.control.c)="copyHandlerIE()" (copy)="copyHandler($event)" class="igx-grid__tbody">
67+
<div igxGridBody (keydown.control.c)="copyHandler($event)" (copy)="copyHandler($event)" class="igx-grid__tbody">
6868
<div class="igx-grid__tbody-content" tabindex="0" (focus)="navigation.focusTbody($event)" [attr.aria-activedescendant]="activeDescendant" (keydown)="navigation.handleNavigation($event)" role="rowgroup" (onDragStop)="selectionService.dragMode = $event"
6969
(onDragScroll)="dragScroll($event)" [igxGridDragSelect]="selectionService.dragMode"
7070
[style.height.px]='totalHeight' [style.width.px]='calcWidth' #tbody (scroll)='preventContainerScroll($event)'>

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,33 @@ export class ColumnHiddenFromMarkupComponent extends BasicGridComponent {
121121
data = SampleTestData.personIDNameData();
122122
}
123123

124+
@Component({
125+
template: `
126+
<igx-grid #grid1 [data]="data" [columnPinning]='true' [width]="'900px'" [height]="'600px'">
127+
<igx-column *ngFor="let c of columns" [field]="c.field"
128+
[header]="c.field"
129+
[movable]="c.movable"
130+
[width]="c.width"
131+
[editable]="true"
132+
[pinned]="c.pinned"
133+
[dataType]="c.type">
134+
</igx-column>
135+
</igx-grid>
136+
`
137+
})
138+
export class GridAddColumnComponent extends BasicGridComponent implements OnInit {
139+
public columns: Array<any>;
140+
data = SampleTestData.contactInfoDataFull();
141+
public ngOnInit(): void {
142+
this.columns = [
143+
{ field: 'ID', width: 150, movable: true, type: 'string', pinned: true },
144+
{ field: 'CompanyName', width: 150, movable: true, type: 'string'},
145+
{ field: 'ContactName', width: 150, movable: true, type: 'string' },
146+
{ field: 'ContactTitle', width: 150, movable: true, type: 'string' },
147+
{ field: 'Address', width: 150, movable: true, type: 'string' }];
148+
}
149+
}
150+
124151
@Component({
125152
template: GridTemplateStrings.declareGrid('', '',
126153
ColumnDefinitions.idNameFormatter)

0 commit comments

Comments
 (0)