Skip to content

Commit 04b6200

Browse files
authored
Do not change focus when ESF keyboard navigation active element is fi… (#13686)
1 parent 04bae2d commit 04b6200

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
@@ -764,8 +764,8 @@ export class IgxExcelStyleSearchComponent implements AfterViewInit, OnDestroy {
764764

765765
private onArrowUpKeyDown() {
766766
if (this.focusedItem && this.focusedItem.index === 0 && this.virtDir.state.startIndex === 0) {
767-
this.searchInput.focus();
768-
this.onFocusOut();
767+
// on ArrowUp the focus stays on the same element if it is the first focused
768+
return;
769769
} else {
770770
this.navigateItem(this.focusedItem ? this.focusedItem.index - 1 : 0);
771771
}
@@ -775,8 +775,8 @@ export class IgxExcelStyleSearchComponent implements AfterViewInit, OnDestroy {
775775
private onArrowDownKeyDown() {
776776
const lastIndex = this.virtDir.igxForOf.length - 1;
777777
if (this.focusedItem && this.focusedItem.index === lastIndex) {
778-
this.cancelButton.nativeElement.focus();
779-
this.onFocusOut();
778+
// on ArrowDown the focus stays on the same element if it is the last focused
779+
return;
780780
} else {
781781
this.navigateItem(this.focusedItem ? this.focusedItem.index + 1 : 0);
782782
}

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
@@ -5487,6 +5487,25 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
54875487
});
54885488
}));
54895489

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

0 commit comments

Comments
 (0)