Skip to content

Commit e6a7787

Browse files
committed
Merge remote-tracking branch 'origin/master' into mdragnev/add-row-transactions
2 parents 0aeaed6 + 6996c2a commit e6a7787

File tree

3 files changed

+42
-17
lines changed

3 files changed

+42
-17
lines changed

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

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2766,7 +2766,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
27662766
});
27672767

27682768
this.hideOverlays();
2769-
const args: IGridScrollEventArgs = { direction: 'horizontal', event: event, scrollPosition: this.headerContainer.scrollPosition };
2769+
const args: IGridScrollEventArgs = { direction: 'horizontal', event: event, scrollPosition: this.headerContainer.scrollPosition };
27702770
this.onScroll.emit(args);
27712771
}
27722772

@@ -2956,7 +2956,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
29562956
const destructor = takeUntil<any>(this.destroy$);
29572957
fromEvent(this.nativeElement, 'focusout').pipe(filter(() => !!this.navigation.activeNode), destructor).subscribe((event) => {
29582958
if (!this.crudService.cell && !!this.navigation.activeNode && (event.target === this.tbody.nativeElement &&
2959-
this.navigation.activeNode.row >= 0 && this.navigation.activeNode.row < this.dataView.length)
2959+
this.navigation.activeNode.row >= 0 && this.navigation.activeNode.row < this.dataView.length)
29602960
|| (event.target === this.theadRow.nativeElement && this.navigation.activeNode.row === -1)
29612961
|| (event.target === this.tfoot.nativeElement && this.navigation.activeNode.row === this.dataView.length)) {
29622962
this.navigation.activeNode = {} as IActiveNode;
@@ -3111,7 +3111,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
31113111
*/
31123112
public generateRowID(): string | number {
31133113
const primaryColumn = this.columnList.find(col => col.field === this.primaryKey);
3114-
const idType = primaryColumn ? primaryColumn.dataType : this.data.length ? typeof(this.data[0][this.primaryKey]) : 'string';
3114+
const idType = primaryColumn ? primaryColumn.dataType : this.data.length ? typeof (this.data[0][this.primaryKey]) : 'string';
31153115
return idType === 'string' ? uuidv4() : FAKE_ROW_ID--;
31163116
}
31173117

@@ -3699,7 +3699,10 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
36993699
}
37003700

37013701
public getColumnByVisibleIndex(index: number): IgxColumnComponent {
3702-
return this.visibleColumns.find((col) => !col.columnGroup && !col.columnLayout && col.visibleIndex === index);
3702+
return this.visibleColumns.find((col) =>
3703+
!col.columnGroup && !col.columnLayout &&
3704+
col.visibleIndex === index
3705+
);
37033706
}
37043707

37053708
/**
@@ -3991,7 +3994,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
39913994
}
39923995

39933996
if (!target.pinned && !column.pinned) {
3994-
this._reorderColumns(column, target, pos, this._unpinnedColumns);
3997+
this._reorderColumns(column, target, pos, this._unpinnedColumns);
39953998
}
39963999

39974000
this._moveColumns(column, target, pos);
@@ -4826,8 +4829,8 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
48264829
protected getTheadRowHeight(): number {
48274830
const height = this.getComputedHeight(this.theadRow.nativeElement);
48284831
return (!this.allowFiltering || (this.allowFiltering && this.filterMode !== FilterMode.quickFilter)) ?
4829-
height - this.getFilterCellHeight() :
4830-
height;
4832+
height - this.getFilterCellHeight() :
4833+
height;
48314834
}
48324835

48334836
/**
@@ -4838,7 +4841,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
48384841
if (this.showToolbar && this.toolbarHtml != null) {
48394842
const height = this.getComputedHeight(this.toolbarHtml.nativeElement);
48404843
toolbarHeight = this.toolbarHtml.nativeElement.firstElementChild ?
4841-
height : 0;
4844+
height : 0;
48424845
}
48434846
return toolbarHeight;
48444847
}
@@ -4851,7 +4854,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
48514854
if (this.footer) {
48524855
const height = this.getComputedHeight(this.footer.nativeElement);
48534856
pagingHeight = this.footer.nativeElement.firstElementChild ?
4854-
height : 0;
4857+
height : 0;
48554858
}
48564859
return pagingHeight;
48574860
}
@@ -6011,7 +6014,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
60116014
}
60126015

60136016
if (this.dataView[rowIndex].detailsData) {
6014-
this.navigation.setActiveNode({row: rowIndex});
6017+
this.navigation.setActiveNode({ row: rowIndex });
60156018
this.cdr.detectChanges();
60166019
}
60176020

@@ -6557,11 +6560,11 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
65576560
}
65586561
if (commit) {
65596562
this.onRowAdded.subscribe(rowData => {
6560-
// A check whether the row is in the current view
6561-
const index = this.dataView.findIndex(data => data[this.primaryKey] === rowData[this.primaryKey]);
6562-
const shouldScroll = this.navigation.shouldPerformVerticalScroll(index, 0);
6563-
const showIndex = shouldScroll ? index : -1;
6564-
this.showSnackbarFor(showIndex);
6563+
// A check whether the row is in the current view
6564+
const index = this.dataView.findIndex(data => data[this.primaryKey] === rowData[this.primaryKey]);
6565+
const shouldScroll = this.navigation.shouldPerformVerticalScroll(index, 0);
6566+
const showIndex = shouldScroll ? index : -1;
6567+
this.showSnackbarFor(showIndex);
65656568
});
65666569
this.gridAPI.submit_add_value();
65676570
this.gridAPI.addRowToData(row.data);

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ export class IgxGridMRLNavigationService extends IgxGridNavigationService {
7676

7777
public shouldPerformVerticalScroll(targetRowIndex: number, visibleColIndex: number): boolean {
7878
if (!super.shouldPerformVerticalScroll(targetRowIndex, visibleColIndex)) { return false; }
79-
if (!this.isDataRow(targetRowIndex)) { return super.shouldPerformVerticalScroll(targetRowIndex, visibleColIndex); }
79+
if (!this.isDataRow(targetRowIndex) || visibleColIndex < 0) {
80+
return super.shouldPerformVerticalScroll(targetRowIndex, visibleColIndex);
81+
}
8082

8183
const targetRow = super.getRowElementByIndex(targetRowIndex);
8284
const containerHeight = this.grid.calcHeight ? Math.ceil(this.grid.calcHeight) : 0;
@@ -144,7 +146,7 @@ export class IgxGridMRLNavigationService extends IgxGridNavigationService {
144146

145147
public performVerticalScrollToCell(rowIndex: number, visibleColIndex: number, cb?: () => void) {
146148
const children = this.parentByChildIndex(visibleColIndex || 0)?.children;
147-
if (!super.isDataRow(rowIndex) || (children && children.length < 2)) {
149+
if (!super.isDataRow(rowIndex) || (children && children.length < 2) || visibleColIndex < 0) {
148150
return super.performVerticalScrollToCell(rowIndex, visibleColIndex, cb);
149151
}
150152

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const GRID_COL_THEAD_CLASS = '.igx-grid__th';
1717
const GRID_MRL_BLOCK = '.igx-grid__mrl-block';
1818

1919
describe('IgxGrid - multi-row-layout #grid', () => {
20+
const DEBOUNCETIME = 60;
2021
configureTestSuite();
2122
beforeAll(async(() => {
2223
TestBed.configureTestingModule({
@@ -1144,6 +1145,25 @@ describe('IgxGrid - multi-row-layout #grid', () => {
11441145
expect(pos.rowIndex).toEqual(0);
11451146
expect(pos.visibleColumnIndex).toEqual(2);
11461147
}));
1148+
1149+
it('should navigate to the proper row in MRL scenario', (async () => {
1150+
const fix = TestBed.createComponent(ColumnLayoutTestComponent);
1151+
const grid = fix.componentInstance.grid;
1152+
const NAVIGATE = 20;
1153+
1154+
fix.detectChanges();
1155+
await wait(DEBOUNCETIME);
1156+
1157+
grid.navigateTo(NAVIGATE);
1158+
1159+
await wait(DEBOUNCETIME);
1160+
fix.detectChanges();
1161+
1162+
expect(grid.verticalScrollContainer.getScroll().scrollTop).toBeGreaterThan(0);
1163+
1164+
const row = grid.getRowByIndex(NAVIGATE);
1165+
expect(GridFunctions.elementInGridView(grid, row.nativeElement)).toBeTruthy();
1166+
}));
11471167
});
11481168

11491169
@Component({

0 commit comments

Comments
 (0)