Skip to content

Commit 8edc5c2

Browse files
Merge pull request #16653 from IgniteUI/rivanova/fix-16649-20.1.x
fix(autocomplete): do not call super.handleKeyDown on Tab - 20.1.x
2 parents 967f0f1 + 4101de4 commit 8edc5c2

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

projects/igniteui-angular/src/lib/directives/autocomplete/autocomplete.directive.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,23 @@ describe('IgxAutocomplete', () => {
7474
fixture.detectChanges();
7575
expect(dropDown.collapsed).toBeTruthy();
7676
}));
77+
it('Should close dropdown on Tab without calling super.handleKeyDown', fakeAsync(() => {
78+
spyOn(autocomplete, 'handleKeyDown').and.callThrough();
79+
spyOn(IgxDropDownItemNavigationDirective.prototype, 'handleKeyDown').and.callThrough();
80+
81+
input.nativeElement.focus();
82+
UIInteractions.setInputElementValue(input, 's', fixture);
83+
tick();
84+
expect(dropDown.collapsed).toBeFalsy();
85+
86+
// IgxDropDownItemNavigationDirective handleKeyDown is not called when dropdown is closed on Tab
87+
UIInteractions.triggerKeyDownEvtUponElem('Tab', input.nativeElement, true);
88+
fixture.detectChanges();
89+
tick();
90+
expect(dropDown.collapsed).toBeTruthy();
91+
expect(autocomplete.handleKeyDown).toHaveBeenCalledTimes(1);
92+
expect(IgxDropDownItemNavigationDirective.prototype.handleKeyDown).toHaveBeenCalledTimes(0);
93+
}));
7794
it('Should open drop down on (Alt+)ArrowUp/ArrowDown', fakeAsync(() => {
7895
UIInteractions.triggerKeyDownEvtUponElem('ArrowDown', input.nativeElement, true);
7996
tick();

projects/igniteui-angular/src/lib/directives/autocomplete/autocomplete.directive.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ export class IgxAutocompleteDirective extends IgxDropDownItemNavigationDirective
273273
case ' ':
274274
case 'home':
275275
case 'end':
276+
case 'tab':
276277
return;
277278
default:
278279
super.handleKeyDown(event);

0 commit comments

Comments
 (0)