Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mrl nav ng 8 update #5011

Merged
merged 3 commits into from
Jun 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions projects/igniteui-angular/src/lib/core/grid-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ export interface GridSelectionRange {
export interface ISelectionNode {
row: number;
column: number;
layout?: IMultiRowLayoutNode;
isSummaryRow?: boolean;
}

export interface IMultiRowLayoutNode {
rowStart: number;
colStart: number;
rowEnd: number;
colEnd: number;
columnVisibleIndex: number;
}

interface ISelectionKeyboardState {
Expand Down
51 changes: 36 additions & 15 deletions projects/igniteui-angular/src/lib/grids/cell.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { DeprecateProperty } from '../core/deprecateDecorators';
templateUrl: './cell.component.html'
})
export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
private _vIndex = -1;

/**
* Gets the column of the cell.
Expand Down Expand Up @@ -233,7 +234,13 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
*/
@HostBinding('attr.data-visibleIndex')
@Input()
visibleColumnIndex = -1;
get visibleColumnIndex() {
return this.column.columnLayoutChild ? this.column.visibleIndex : this._vIndex;
}

set visibleColumnIndex(val) {
this._vIndex = val;
}

/**
* Gets the ID of the cell.
Expand Down Expand Up @@ -497,7 +504,17 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
}

protected get selectionNode(): ISelectionNode {
return { row: this.rowIndex, column: this.visibleColumnIndex };
return {
row: this.rowIndex,
column: this.column.columnLayoutChild ? this.column.parent.visibleIndex : this.visibleColumnIndex,
layout: this.column.columnLayoutChild ? {
rowStart: this.column.rowStart,
colStart: this.column.colStart,
rowEnd: this.column.rowEnd,
colEnd: this.column.colEnd,
columnVisibleIndex: this.visibleColumnIndex
} : null
};
}

protected isInCompositionMode = false;
Expand Down Expand Up @@ -689,6 +706,9 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
* @internal
*/
pointerup = () => {
if (this.grid.hasColumnLayouts) {
this.grid.navigation.setStartNavigationCell(this.colStart, this.rowStart, null);
}
if (this.selectionService.pointerUp(this.selectionNode, this.grid.onRangeSelection)) {
this.grid.cdr.detectChanges();
}
Expand Down Expand Up @@ -743,7 +763,8 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
this.focused = true;
this.row.focused = true;
this._updateCellSelectionStatus();
if (!this.selectionService.isActiveNode(this.selectionNode)) {
if (!this.selectionService.isActiveNode(this.selectionNode) ||
this.grid.hasColumnLayouts) {
this.grid.onSelection.emit({ cell: this, event });
}
this.selectionService.activeElement = this.selectionNode;
Expand Down Expand Up @@ -773,25 +794,25 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {

protected handleTab(shift: boolean) {
if (shift) {
this.grid.navigation.performShiftTabKey(this.row.nativeElement, this.rowIndex, this.visibleColumnIndex);
this.grid.navigation.performShiftTabKey(this.row.nativeElement, this.selectionNode);
} else {
this.grid.navigation.performTab(this.row.nativeElement, this.rowIndex, this.visibleColumnIndex);
this.grid.navigation.performTab(this.row.nativeElement, this.selectionNode);
}
}

protected handleEnd(ctrl: boolean) {
if (ctrl) {
this.grid.navigation.goToLastCell();
} else {
this.grid.navigation.onKeydownEnd(this.rowIndex);
this.grid.navigation.onKeydownEnd(this.rowIndex, false, this.rowStart);
}
}

protected handleHome(ctrl: boolean) {
if (ctrl) {
this.grid.navigation.goToFirstCell();
} else {
this.grid.navigation.onKeydownHome(this.rowIndex);
this.grid.navigation.onKeydownHome(this.rowIndex, false, this.rowStart);
}
}

Expand Down Expand Up @@ -865,34 +886,34 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
case 'arrowleft':
case 'left':
if (ctrl) {
this.grid.navigation.onKeydownHome(node.row);
this.grid.navigation.onKeydownHome(node.row, false, this.rowStart);
break;
}
this.grid.navigation.onKeydownArrowLeft(this.nativeElement, node.row, node.column);
this.grid.navigation.onKeydownArrowLeft(this.nativeElement, this.selectionNode);
break;
case 'arrowright':
case 'right':
if (ctrl) {
this.grid.navigation.onKeydownEnd(node.row);
this.grid.navigation.onKeydownEnd(node.row, false, this.rowStart);
break;
}
this.grid.navigation.onKeydownArrowRight(this.nativeElement, node.row, node.column);
this.grid.navigation.onKeydownArrowRight(this.nativeElement, this.selectionNode);
break;
case 'arrowup':
case 'up':
if (ctrl) {
this.grid.navigation.navigateTop(node.column);
this.grid.navigation.navigateTop(this.visibleColumnIndex);
break;
}
this.grid.navigation.navigateUp(this.row.nativeElement, node.row, node.column);
this.grid.navigation.navigateUp(this.row.nativeElement, this.selectionNode);
break;
case 'arrowdown':
case 'down':
if (ctrl) {
this.grid.navigation.navigateBottom(node.column);
this.grid.navigation.navigateBottom(this.visibleColumnIndex);
break;
}
this.grid.navigation.navigateDown(this.row.nativeElement, node.row, node.column);
this.grid.navigation.navigateDown(this.row.nativeElement, this.selectionNode);
break;
case 'enter':
case 'f2':
Expand Down
Loading