Skip to content

Commit 91ed5a8

Browse files
committed
chore(combo): apply suggestions
1 parent 8180a5d commit 91ed5a8

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
@@ -3662,13 +3662,14 @@ describe('igxCombo', () => {
36623662

36633663
describe('Zoneless', () => {
36643664
beforeEach(async () => {
3665+
TestBed.resetTestingModule();
36653666
await TestBed.configureTestingModule({
36663667
imports: [
36673668
NoopAnimationsModule,
3668-
IgxComboComponent,
3669+
IgxComboSampleComponent,
36693670
],
36703671
providers: [
3671-
provideZonelessChangeDetection()
3672+
provideZonelessChangeDetection(),
36723673
]
36733674
}).compileComponents();
36743675

@@ -3677,21 +3678,23 @@ describe('igxCombo', () => {
36773678
combo = fixture.componentInstance.combo;
36783679
});
36793680

3680-
it('should not reproduce NG0100 when virtualized combo items update on scroll - issue #17310', async () => {
3681+
it('should not reproduce NG0100 when virtualized combo items update on scroll - issue #17310', fakeAsync(() => {
36813682
combo.open();
3682-
await fixture.whenStable();
3683+
tick();
3684+
fixture.detectChanges();
36833685

36843686
const scrollEl = combo.virtualScrollContainer.getScroll();
36853687
expect(scrollEl).toBeTruthy();
36863688

3689+
scrollEl.scrollTop = 300;
3690+
scrollEl.dispatchEvent(new Event('scroll'));
3691+
tick(100);
3692+
36873693
expect(() => {
3688-
scrollEl.scrollTop = 300;
3689-
scrollEl.dispatchEvent(new Event('scroll'));
36903694

3691-
fixture.whenStable();
36923695
fixture.detectChanges();
36933696
}).not.toThrowError(/NG0100|ExpressionChangedAfterItHasBeenCheckedError/);
3694-
});
3697+
}));
36953698

36963699
it('should not reproduce NG0100 related to active descendant on scroll - issue #17310', fakeAsync(() => {
36973700
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)