Skip to content

Commit

Permalink
Merge pull request #2993 from IgniteUI/ddincheva/expandCollapse-6.2.x
Browse files Browse the repository at this point in the history
Expand/Collapse tree row and groupby row
  • Loading branch information
zdrawku authored Nov 19, 2018
2 parents 1a00102 + 4928476 commit 7f1c98b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,17 @@ export class IgxGridGroupByRowComponent {
* this.grid1.rowList.first.toggle()
* ```
*/
public toggle(key?) {
const shouldExpand = (!key && !this.expanded) || (key && !this.expanded && (key === 'arrowleft' || key === 'left'));
this.handleToggleScroll();
if (!shouldExpand) {
this.grid.verticalScrollContainer.getVerticalScroll().dispatchEvent(new Event('scroll'));
public toggle() {
const isVirtualized = !this.grid.verticalScrollContainer.dc.instance.notVirtual;
const groupRowIndex = this.index;
this.grid.toggleGroup(this.groupRow);
if (isVirtualized) {
this.grid.verticalScrollContainer.onChunkLoad
.pipe(first())
.subscribe(() => {
const groupRow = this.grid.nativeElement.querySelector(`[data-rowIndex="${groupRowIndex}"]`);
if (groupRow) { groupRow.focus(); }
});
}
}

Expand All @@ -185,7 +191,10 @@ export class IgxGridGroupByRowComponent {

if (this.isToggleKey(key)) {
if (!alt) { return; }
this.toggle(key);
if ((this.expanded && (key === 'left' || key === 'arrowleft')) ||
(!this.expanded && (key === 'right' || key === 'arrowright'))) {
this.toggle();
}
return;
}
const args = { cell: null, groupRow: this, event: event, cancel: false };
Expand Down Expand Up @@ -252,16 +261,5 @@ export class IgxGridGroupByRowComponent {
private isToggleKey(key) {
return ['left', 'right', 'arrowleft', 'arrowright'].indexOf(key) !== -1;
}
private handleToggleScroll() {
if (this.grid.rowList.length > 0 && this.grid.rowList.last.index ===
this.grid.verticalScrollContainer.igxForOf.length - 1) {
const groupRowIndex = this.index;
this.grid.verticalScrollContainer.onChunkLoad
.pipe(first())
.subscribe(() => {
this.grid.nativeElement.querySelector(`[data-rowIndex="${groupRowIndex}"]`).focus();
});
}
this.grid.toggleGroup(this.groupRow);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,15 @@ export class IgxTreeGridAPIService extends GridBaseAPIService<IgxTreeGridCompone
grid.expansionStates = expandedStates;

if (isScrolledToBottom) {
grid.nativeElement.focus({preventScroll: true});
grid.verticalScrollContainer.onChunkLoad
.pipe(first())
.subscribe(() => {
grid.nativeElement.querySelector(
`[data-rowIndex="${groupRowIndex}"][data-visibleindex="${visibleColumnIndex}"]`).focus();
});
}
if (expanded) {
if (expanded || (!expanded && isScrolledToBottom)) {
grid.verticalScrollContainer.getVerticalScroll().dispatchEvent(new Event('scroll'));
if (shouldScroll) {
grid.parentVirtDir.getHorizontalScroll().dispatchEvent(new Event('scroll'));
Expand Down

0 comments on commit 7f1c98b

Please sign in to comment.