Skip to content

Commit 6cffd4e

Browse files
authored
Do not change focus when ESF keyboard navigation active element is fi… (#13687)
1 parent d59d725 commit 6cffd4e

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

projects/igniteui-angular/src/lib/grids/filtering/excel-style/excel-style-search.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,8 @@ export class IgxExcelStyleSearchComponent implements AfterViewInit, OnDestroy {
769769

770770
private onArrowUpKeyDown() {
771771
if (this.focusedItem && this.focusedItem.index === 0 && this.virtDir.state.startIndex === 0) {
772-
this.searchInput.focus();
773-
this.onFocusOut();
772+
// on ArrowUp the focus stays on the same element if it is the first focused
773+
return;
774774
} else {
775775
this.navigateItem(this.focusedItem ? this.focusedItem.index - 1 : 0);
776776
}
@@ -780,8 +780,8 @@ export class IgxExcelStyleSearchComponent implements AfterViewInit, OnDestroy {
780780
private onArrowDownKeyDown() {
781781
const lastIndex = this.virtDir.igxForOf.length - 1;
782782
if (this.focusedItem && this.focusedItem.index === lastIndex) {
783-
this.cancelButton.nativeElement.focus();
784-
this.onFocusOut();
783+
// on ArrowDown the focus stays on the same element if it is the last focused
784+
return;
785785
} else {
786786
this.navigateItem(this.focusedItem ? this.focusedItem.index + 1 : 0);
787787
}

projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5480,6 +5480,25 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
54805480
});
54815481
}));
54825482

5483+
it('Should not lose focus with arrowUp/arrowDown when navigating inside search list', fakeAsync(() => {
5484+
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'Downloads');
5485+
const searchComponent = GridFunctions.getExcelStyleSearchComponent(fix);
5486+
const list = searchComponent.querySelector('igx-list');
5487+
list.dispatchEvent(new Event('focus'));
5488+
tick(DEBOUNCETIME);
5489+
fix.detectChanges();
5490+
const listItems = list.querySelectorAll('igx-list-item');
5491+
5492+
// we expect only the first list item to be active when the list is focused
5493+
expect(listItems[0].classList.contains("igx-list__item-base--active")).toBeTrue();
5494+
expect(listItems[1].classList.contains("igx-list__item-base--active")).toBeFalse();
5495+
5496+
// on arrow up the focus should stay on the first element and not on the search input
5497+
UIInteractions.triggerKeyDownEvtUponElem('arrowup', list, true);
5498+
fix.detectChanges();
5499+
expect(listItems[0].classList.contains("igx-list__item-base--active")).toBeTrue();
5500+
}));
5501+
54835502
it('Should add list items to current filtered items when "Add to current filter selection" is selected.', fakeAsync(() => {
54845503
const totalListItems = [];
54855504

0 commit comments

Comments
 (0)