Skip to content

Commit ca67a86

Browse files
refactor(simple-combo): bind to contentSizeChange of igxFort to prevent flicker
- close the dropdown with Alt+ArrowUp
1 parent 23d882e commit ca67a86

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

projects/igniteui-angular/src/lib/simple-combo/simple-combo.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
</ng-container>
4444
<div #dropdownItemContainer class="igx-combo__content" [style.overflow]="'hidden'"
4545
[style.maxHeight.px]="itemsMaxHeight" [igxDropDownItemNavigation]="dropdown" (focus)="dropdown.onFocus()"
46-
[tabindex]="dropdown.collapsed ? -1 : 0" role="listbox" [attr.id]="dropdown.id">
46+
[tabindex]="dropdown.collapsed ? -1 : 0" role="listbox" [attr.id]="dropdown.id" (keydown)="handleItemKeyDown($event)">
4747
<igx-combo-item role="option" [singleMode]="true" [itemHeight]='itemHeight' (click)="close()" *igxFor="let item of data
4848
| comboFiltering:filterValue:displayKey:filteringOptions:true
4949
| comboGrouping:groupKey:valueKey:groupSortingDirection;

projects/igniteui-angular/src/lib/simple-combo/simple-combo.component.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { IgxButtonModule } from '../directives/button/button.directive';
1818
import { IgxForOfModule } from '../directives/for-of/for_of.directive';
1919
import { IgxRippleModule } from '../directives/ripple/ripple.directive';
2020
import { IgxTextSelectionModule } from '../directives/text-selection/text-selection.directive';
21-
import { IgxToggleDirective, IgxToggleModule } from '../directives/toggle/toggle.directive';
21+
import { IgxToggleModule } from '../directives/toggle/toggle.directive';
2222
import { IgxDropDownModule } from '../drop-down/public_api';
2323
import { IgxIconModule, IgxIconService } from '../icon/public_api';
2424
import { IgxInputGroupModule, IgxInputGroupType, IGX_INPUT_GROUP_TYPE } from '../input-group/public_api';
@@ -142,14 +142,7 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
142142

143143
/** @hidden @internal */
144144
public ngAfterViewInit() {
145-
this.dropdown.opened.pipe(takeUntil(this.destroy$)).subscribe(() => {
146-
if (this.composing) {
147-
this.comboInput.focus();
148-
}
149-
if (this.comboInput.value.length === 0) {
150-
this.dropdown.navigateFirst();
151-
this.dropdownContainer.nativeElement.focus();
152-
}
145+
this.virtDir.contentSizeChange.pipe(takeUntil(this.destroy$)).subscribe(() => {
153146
if (this.selection.length > 0) {
154147
const index = this.virtDir.igxForOf.findIndex(e => {
155148
let current = e[this.valueKey];
@@ -161,6 +154,15 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
161154
this.dropdown.navigateItem(index);
162155
}
163156
});
157+
this.dropdown.opened.pipe(takeUntil(this.destroy$)).subscribe(() => {
158+
if (this.composing) {
159+
this.comboInput.focus();
160+
}
161+
if (this.comboInput.value.length === 0) {
162+
this.dropdown.navigateFirst();
163+
this.dropdownContainer.nativeElement.focus();
164+
}
165+
});
164166
this.dropdown.closed.pipe(takeUntil(this.destroy$)).subscribe(() => {
165167
this.composing = false;
166168
});
@@ -220,6 +222,13 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
220222
}
221223
}
222224

225+
/** @hidden @internal */
226+
public handleItemKeyDown(event: KeyboardEvent) {
227+
if (event.key === this.platformUtil.KEYMAP.ARROW_UP && event.altKey) {
228+
this.close();
229+
}
230+
}
231+
223232
/** @hidden @internal */
224233
public getEditElement(): HTMLElement {
225234
return this.comboInput.nativeElement;

0 commit comments

Comments
 (0)