Skip to content

Commit 3a1937c

Browse files
committed
fix(combo): use isEqual to handle both complex types and NaN/falsy values
1 parent eae6c15 commit 3a1937c

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

projects/igniteui-angular/src/lib/combo/combo.common.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { caseSensitive } from '@igniteui/material-icons-extended';
2828
import { noop, Subject } from 'rxjs';
2929
import { takeUntil } from 'rxjs/operators';
3030
import { IgxSelectionAPIService } from '../core/selection';
31-
import { CancelableBrowserEventArgs, cloneArray, IBaseCancelableBrowserEventArgs, IBaseEventArgs, isNaNvalue, rem } from '../core/utils';
31+
import { CancelableBrowserEventArgs, cloneArray, IBaseCancelableBrowserEventArgs, IBaseEventArgs, rem } from '../core/utils';
3232
import { SortingDirection } from '../data-operations/sorting-strategy';
3333
import { IForOfState, IgxForOfDirective } from '../directives/for-of/for_of.directive';
3434
import { IgxIconService } from '../icon/icon.service';
@@ -46,6 +46,7 @@ import { ComboResourceStringsEN, IComboResourceStrings } from '../core/i18n/comb
4646
import { getCurrentResourceStrings } from '../core/i18n/resources';
4747
import { DOCUMENT } from '@angular/common';
4848
import { Size } from '../grids/common/enums';
49+
import { isEqual } from 'lodash-es';
4950

5051
export const IGX_COMBO_COMPONENT = /*@__PURE__*/new InjectionToken<IgxComboBase>('IgxComboComponentToken');
5152

@@ -1288,9 +1289,7 @@ export abstract class IgxComboBaseDirective implements IgxComboBase, AfterViewCh
12881289
}
12891290

12901291
return keys.map(key => {
1291-
const item = isNaNvalue(key)
1292-
? this.data.find(entry => isNaNvalue(entry[this.valueKey]))
1293-
: this.data.find(entry => entry[this.valueKey] === key);
1292+
const item = this.data.find(entry => isEqual(entry[this.valueKey], key));
12941293

12951294
return item !== undefined ? item : { [this.valueKey]: key };
12961295
});

projects/igniteui-angular/src/lib/core/utils.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,6 @@ export const isEqual = (obj1, obj2): boolean => {
226226
return obj1 === obj2;
227227
};
228228

229-
/**
230-
* Checks if provided variable is the value NaN
231-
*
232-
* @param value Value to check
233-
* @returns true if provided variable is NaN
234-
* @hidden
235-
*/
236-
export const isNaNvalue = (value: any): boolean => isNaN(value) && value !== undefined && typeof value !== 'string';
237-
238229
/**
239230
* Utility service taking care of various utility functions such as
240231
* detecting browser features, general cross browser DOM manipulation, etc.
@@ -624,8 +615,8 @@ export function* intoChunks<T>(arr: T[], size: number) {
624615
}
625616

626617
/**
627-
* @param size
628-
* @returns string that represents the --component-size default value
618+
* @param size
619+
* @returns string that represents the --component-size default value
629620
*/
630621
export function getComponentCssSizeVar(size: string) {
631622
switch (size) {

0 commit comments

Comments
 (0)