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

Update focused cell after column moving is performed #3524

Merged
merged 4 commits into from
Jan 7, 2019
Merged
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
33 changes: 27 additions & 6 deletions projects/igniteui-angular/src/lib/grids/grid.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ export class IgxColumnMovingService {
rowID: any
};

public activeElement: {
tag: string,
column: IgxColumnComponent,
rowIndex: number
};

get column(): IgxColumnComponent {
return this._column;
}
Expand Down Expand Up @@ -275,6 +281,20 @@ export class IgxColumnMovingDragDirective extends IgxDragDirective {
rowID: currSelection.rowID
};
}
// tslint:disable-next-line:no-bitwise
if (document.activeElement.compareDocumentPosition(this.column.grid.nativeElement) & Node.DOCUMENT_POSITION_CONTAINS) {
if (parseInt(document.activeElement.getAttribute('data-visibleIndex'), 10) !== this.column.visibleIndex) {
(document.activeElement as HTMLElement).blur();
return;
}
this.cms.activeElement = {
tag: document.activeElement.tagName.toLowerCase() === 'igx-grid-summary-cell' ?
document.activeElement.tagName.toLowerCase() : '',
column: this.column,
rowIndex: parseInt(document.activeElement.getAttribute('data-rowindex'), 10)
};
(document.activeElement as HTMLElement).blur();
}

const args = {
source: this.column
Expand Down Expand Up @@ -528,12 +548,13 @@ export class IgxColumnMovingDropDirective extends IgxDropDirective implements On
rowID: this.cms.selection.rowID,
columnID: this.column.grid.columnList.toArray().indexOf(this.cms.selection.column)
}]));

const cell = this.column.grid.getCellByKey(this.cms.selection.rowID, this.cms.selection.column.field);

if (cell) {
cell.nativeElement.focus();
}
}
if (this.cms.activeElement) {
const gridEl = this.column.grid.nativeElement;
const activeEl = gridEl.querySelector(`${this.cms.activeElement.tag}[data-rowindex="${this.cms.activeElement.rowIndex}"]` +
`[data-visibleIndex="${this.cms.activeElement.column.visibleIndex}"]`);
if (activeEl) { activeEl.focus(); }
this.cms.activeElement = null;
}

this.column.grid.draggedColumn = null;
Expand Down