Skip to content

Commit bcf8ea1

Browse files
committed
chore(combo): apply suggestions
1 parent db45889 commit bcf8ea1

3 files changed

Lines changed: 16 additions & 15 deletions

File tree

projects/igniteui-angular/combo/src/combo/combo-dropdown.component.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class IgxComboDropDownComponent extends IgxDropDownComponent implements I
5959
/**
6060
* @hidden @internal
6161
*/
62-
public override get focusedItem(): IgxDropDownItemBaseDirective {
62+
public override get focusedItem(): IgxDropDownItemBaseDirective | null {
6363
return super.focusedItem;
6464
}
6565

@@ -75,17 +75,15 @@ export class IgxComboDropDownComponent extends IgxDropDownComponent implements I
7575
}
7676

7777
/** @hidden @internal */
78-
public override set focusedItem(item: IgxDropDownItemBaseDirective) {
78+
public override set focusedItem(item: IgxDropDownItemBaseDirective | null) {
7979
if (!item) {
8080
this._activeDescendantId = null;
8181
} else if (item.id !== undefined) {
8282
this._activeDescendantId = item.id;
8383
} else {
8484
// Virtual { value, index } object passed by navigateItem() under virtual scrolling.
8585
const resolved = this.children?.find(e => e.index === item.index);
86-
if (resolved) {
87-
this._activeDescendantId = resolved.id;
88-
}
86+
this._activeDescendantId = resolved?.id ?? null;
8987
}
9088
super.focusedItem = item;
9189
}
@@ -177,7 +175,7 @@ export class IgxComboDropDownComponent extends IgxDropDownComponent implements I
177175
return;
178176
}
179177
this.comboAPI.set_selected_item(item.itemID);
180-
this._activeDescendantId = item.id;
178+
this._activeDescendantId = item.id ?? null;
181179
this._focusedItem = item;
182180
this.combo.setActiveDescendant();
183181
}

projects/igniteui-angular/combo/src/combo/combo.component.spec.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3709,13 +3709,14 @@ describe('igxCombo', () => {
37093709

37103710
describe('Zoneless', () => {
37113711
beforeEach(async () => {
3712+
TestBed.resetTestingModule();
37123713
await TestBed.configureTestingModule({
37133714
imports: [
37143715
NoopAnimationsModule,
3715-
IgxComboComponent,
3716+
IgxComboSampleComponent,
37163717
],
37173718
providers: [
3718-
provideZonelessChangeDetection()
3719+
provideZonelessChangeDetection(),
37193720
]
37203721
}).compileComponents();
37213722

@@ -3724,21 +3725,23 @@ describe('igxCombo', () => {
37243725
combo = fixture.componentInstance.combo;
37253726
});
37263727

3727-
it('should not reproduce NG0100 when virtualized combo items update on scroll - issue #17310', async () => {
3728+
it('should not reproduce NG0100 when virtualized combo items update on scroll - issue #17310', fakeAsync(() => {
37283729
combo.open();
3729-
await fixture.whenStable();
3730+
tick();
3731+
fixture.detectChanges();
37303732

37313733
const scrollEl = combo.virtualScrollContainer.getScroll();
37323734
expect(scrollEl).toBeTruthy();
37333735

3736+
scrollEl.scrollTop = 300;
3737+
scrollEl.dispatchEvent(new Event('scroll'));
3738+
tick(100);
3739+
37343740
expect(() => {
3735-
scrollEl.scrollTop = 300;
3736-
scrollEl.dispatchEvent(new Event('scroll'));
37373741

3738-
fixture.whenStable();
37393742
fixture.detectChanges();
37403743
}).not.toThrowError(/NG0100|ExpressionChangedAfterItHasBeenCheckedError/);
3741-
});
3744+
}));
37423745

37433746
it('should not reproduce NG0100 related to active descendant on scroll - issue #17310', fakeAsync(() => {
37443747
combo.toggle();

projects/igniteui-angular/drop-down/src/drop-down/drop-down.base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export abstract class IgxDropDownBaseDirective implements IDropDownList, OnInit
173173
* the IgxDropDownNavigationDirective host element.
174174
*/
175175
public get activeDescendant (): string | null {
176-
return this.focusedItem ? this.focusedItem.id : null;
176+
return this.focusedItem?.id ?? null;
177177
}
178178

179179
/**

0 commit comments

Comments
 (0)