Skip to content

Commit 2d72d8f

Browse files
authored
Merge branch 'master' into ddincheva/summaryHeight-master
2 parents ee1c8f2 + e0228c9 commit 2d72d8f

File tree

7 files changed

+70
-20
lines changed

7 files changed

+70
-20
lines changed

projects/igniteui-angular/src/lib/chips/chip.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
(enter)="onChipDragEnterHandler($event)"
1313
(dropped)="onChipDrop($event)">
1414

15-
<div [ngClass]="selectClass(selected)" (transitionend)="onSelectTransitionDone($event)">
15+
<div #selectContainer [ngClass]="selectClass(selected)">
1616
<ng-container *ngTemplateOutlet="selectIconTemplate"></ng-container>
1717
</div>
1818

projects/igniteui-angular/src/lib/chips/chip.component.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import {
2121
IDropDroppedEventArgs
2222
} from '../directives/drag-drop/drag-drop.directive';
2323
import { IBaseEventArgs } from '../core/utils';
24+
import { fromEvent } from 'rxjs';
25+
import { take, filter } from 'rxjs/operators';
2426

2527

2628
export interface IBaseChipEventArgs extends IBaseEventArgs {
@@ -376,6 +378,12 @@ export class IgxChipComponent extends DisplayDensityBase {
376378
@ViewChild('chipArea', { read: ElementRef, static: true })
377379
public chipArea: ElementRef;
378380

381+
/**
382+
* @hidden
383+
*/
384+
@ViewChild('selectContainer', { read: ElementRef, static: true })
385+
public selectContainer: ElementRef;
386+
379387
/**
380388
* @hidden
381389
*/
@@ -442,6 +450,10 @@ export class IgxChipComponent extends DisplayDensityBase {
442450
cancel: false
443451
};
444452

453+
fromEvent(this.selectContainer.nativeElement, 'transitionend')
454+
.pipe(filter<TransitionEvent>(event => event.propertyName === 'width'), take(1))
455+
.subscribe(event => this.onSelectTransitionDone(event));
456+
445457
if (newValue && !this._selected) {
446458
onSelectArgs.selected = true;
447459
this.onSelection.emit(onSelectArgs);
@@ -463,7 +475,7 @@ export class IgxChipComponent extends DisplayDensityBase {
463475
}
464476

465477
public onSelectTransitionDone(event) {
466-
if (event.propertyName === 'width' && !!event.target.tagName) {
478+
if (!!event.target.tagName) {
467479
// Trigger onSelectionDone on when `width` property is changed and the target is valid element(not comment).
468480
this.onSelectionDone.emit({
469481
owner: this,

projects/igniteui-angular/src/lib/chips/chip.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ describe('IgxChip', () => {
423423
});
424424

425425
await wait(400);
426-
expect(secondChipComp.onSelectionDone.emit).toHaveBeenCalled();
426+
expect(secondChipComp.onSelectionDone.emit).toHaveBeenCalledTimes(1);
427427
expect(secondChipComp.onSelectionDone.emit).not.toHaveBeenCalledWith({
428428
originalEvent: null,
429429
owner: secondChipComp

projects/igniteui-angular/src/lib/core/styles/components/chip/_chip-theme.scss

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -430,13 +430,13 @@
430430
%igx-chip__select {
431431
display: inline-flex;
432432
align-items: center;
433-
z-index: 1;
433+
width: 18px;
434434
opacity: 1;
435-
transition: opacity 120ms $ease-in-out-quad;
435+
z-index: 1;
436+
transition: opacity 120ms $ease-out-quad, width 120ms $ease-out-quad;
436437

437438
> * {
438-
width: 18px !important;
439-
transition: width 120ms $ease-in-out-quad;
439+
width: inherit !important;
440440
}
441441

442442
+ igx-prefix,
@@ -446,13 +446,10 @@
446446
}
447447

448448
%igx-chip__select--hidden {
449+
width: 0;
449450
opacity: 0;
450451
z-index: -1;
451452

452-
> * {
453-
width: 0 !important;
454-
}
455-
456453
+ igx-prefix,
457454
+ [igxPrefix] {
458455
margin-#{$left}: 0;

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,9 @@ export class IgxGridNavigationService {
401401
verticalScroll.scrollTop === verticalScroll.scrollHeight - this.grid.verticalScrollContainer.igxForContainerSize) {
402402
const rowIndex = this.grid.dataView.length - 1;
403403
const row = this.grid.nativeElement.querySelector(`[data-rowindex="${rowIndex}"]`) as HTMLElement;
404-
if (row && row.tagName.toLowerCase() === 'igx-grid-groupby-row') {
404+
const isRowTarget = row.tagName.toLowerCase() === 'igx-grid-groupby-row' ||
405+
this.grid.isDetailRecord(this.grid.dataView[rowIndex]);
406+
if (row && isRowTarget) {
405407
row.focus();
406408
return;
407409
}
@@ -413,7 +415,9 @@ export class IgxGridNavigationService {
413415
.pipe(first()).subscribe(() => {
414416
const rowIndex = this.grid.dataView.length - 1;
415417
const row = this.grid.nativeElement.querySelector(`[data-rowindex="${rowIndex}"]`) as HTMLElement;
416-
if (row && row.tagName.toLowerCase() === 'igx-grid-groupby-row') {
418+
const isRowTarget = row.tagName.toLowerCase() === 'igx-grid-groupby-row' ||
419+
this.grid.isDetailRecord(this.grid.dataView[rowIndex]);
420+
if (row && isRowTarget) {
417421
row.focus();
418422
return;
419423
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
</igx-grid-summary-row>
140140
</ng-template>
141141
<ng-template #detail_template_container let-rowIndex="index" let-rowData>
142-
<div detail='true' style="overflow:auto;width: 100%;" tabindex="0" #detailsContainer (keydown)='detailsKeyboardHandler($event, rowIndex, detailsContainer)' [attr.data-rowindex]='rowIndex'
142+
<div detail='true' style="overflow:auto;width: 100%;" (focusin)='detailsViewFocused(detailsContainer, rowIndex)' tabindex="0" #detailsContainer (keydown)='detailsKeyboardHandler($event, rowIndex, detailsContainer)' [attr.data-rowindex]='rowIndex'
143143
[ngClass]="{
144144
'igx-grid__tr-container': true
145145
}">

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

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
Component, ChangeDetectionStrategy, Input, Output, EventEmitter, ContentChild, ViewChildren,
3-
QueryList, ViewChild, ElementRef, TemplateRef, DoCheck, AfterContentInit, HostBinding, forwardRef, OnInit, AfterViewInit
3+
QueryList, ViewChild, ElementRef, TemplateRef, DoCheck, AfterContentInit, HostBinding, forwardRef, OnInit, AfterViewInit, HostListener
44
} from '@angular/core';
55
import { GridBaseAPIService } from '../api.service';
66
import { IgxGridBaseDirective } from '../grid-base.directive';
@@ -347,8 +347,8 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
347347
}
348348

349349
/**
350-
*@hidden
351-
*/
350+
*@hidden
351+
*/
352352
@Output()
353353
public groupingExpansionStateChange = new EventEmitter<IGroupByExpandState[]>();
354354

@@ -553,6 +553,7 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
553553

554554
private _expansionStates: Map<any, boolean> = new Map<any, boolean>();
555555

556+
556557
/**
557558
* Returns a list of key-value pairs [row ID, expansion state]. Includes only states that differ from the default one.
558559
* ```typescript
@@ -571,6 +572,14 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
571572
@Output()
572573
public expansionStatesChange = new EventEmitter<Map<any, boolean>>();
573574

575+
/**
576+
*@hidden
577+
*/
578+
@Output()
579+
private _focusIn = new EventEmitter<any>();
580+
@HostListener('focusin') onFocusIn() {
581+
this._focusIn.emit();
582+
}
574583

575584
/**
576585
* Sets a list of key-value pairs [row ID, expansion state].
@@ -682,8 +691,21 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
682691
this.verticalScrollContainer.addScrollTop(evt.target.scrollTop);
683692
evt.target.scrollTop = 0;
684693
this.verticalScrollContainer.onChunkLoad.pipe(first()).subscribe(() => {
685-
// Some browsers (like Edge/IE) lose focus after scrolling.
686-
(activeElem as any).focus();
694+
const active = this.selectionService.activeElement;
695+
const currRow = (this.navigation as any).getRowByIndex(active.row, '');
696+
// check if the focused element was a child of the details view
697+
if (this.isDetailRecord(active.row) && currRow && currRow.contains(activeElem)) {
698+
// Some browsers (like Edge/IE) lose focus after scrolling even when the element was in the DOM.
699+
(activeElem as any).focus({ preventScroll: true });
700+
return;
701+
}
702+
const nextCellTarget = this.navigation.getCellElementByVisibleIndex(active.row, active.column);
703+
const nextRowTarget = (this.navigation as any).getRowByIndex(active.row + 1, '');
704+
if (nextCellTarget) {
705+
nextCellTarget.focus({ preventScroll: true });
706+
} else if (nextRowTarget) {
707+
nextRowTarget.focus({ preventScroll: true });
708+
}
687709
});
688710
}
689711
}
@@ -698,6 +720,13 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
698720
return rec;
699721
}
700722

723+
public detailsViewFocused(container, rowIndex) {
724+
this.selectionService.activeElement = {
725+
row: rowIndex,
726+
column: this.selectionService.activeElement ? this.selectionService.activeElement.column : 0
727+
};
728+
}
729+
701730
public detailsKeyboardHandler(event, rowIndex, container) {
702731
const colIndex = this.selectionService.activeElement ? this.selectionService.activeElement.column : 0;
703732
const shift = event.shiftKey;
@@ -706,12 +735,20 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
706735
const target = event.target;
707736
if (key === 'tab') {
708737
event.stopPropagation();
738+
const lastColIndex = this.unpinnedColumns[this.unpinnedColumns.length - 1].visibleIndex;
709739
if (shift && target === container) {
710740
// shift + tab from details to data row
711741
event.preventDefault();
712-
const lastColIndex = this.unpinnedColumns[this.unpinnedColumns.length - 1].visibleIndex;
713742
this.navigateTo(rowIndex - 1, lastColIndex,
714743
(args) => args.target.nativeElement.focus());
744+
} else if (!shift) {
745+
// when the next element is focused via tab check if it is an element outside the details view
746+
// if so we have exited the details view and focus should move to the first cell in the next row
747+
this._focusIn.pipe(first()).subscribe(() => {
748+
if (!container.contains(document.activeElement)) {
749+
this.navigation.performTab(container, {row: rowIndex, column: lastColIndex});
750+
}
751+
});
715752
}
716753
} else if (key === 'arrowup' && !ctrl && target === container) {
717754
this.navigation.navigateUp(container, {row: rowIndex, column: colIndex});

0 commit comments

Comments
 (0)