diff --git a/projects/swimlane/ngx-ui/CHANGELOG.md b/projects/swimlane/ngx-ui/CHANGELOG.md
index 5256932fe..d02a6547e 100644
--- a/projects/swimlane/ngx-ui/CHANGELOG.md
+++ b/projects/swimlane/ngx-ui/CHANGELOG.md
@@ -4,6 +4,7 @@
- Fix (`ngx-date-range-picker`): Preset values now retain their relative expressions when cancel is clicked, instead of being converted to timestamps
- Fix (`ngx-date-range-picker`): Fix highlight the date for given `selectedRange` values.
+- Fix (`ngx-select`): Fix filtering of numeric option values.
## 50.1.3 (2025-09-23)
diff --git a/projects/swimlane/ngx-ui/src/lib/components/select/contains-filter.util.spec.ts b/projects/swimlane/ngx-ui/src/lib/components/select/contains-filter.util.spec.ts
index c12de6d55..bde4ca16c 100644
--- a/projects/swimlane/ngx-ui/src/lib/components/select/contains-filter.util.spec.ts
+++ b/projects/swimlane/ngx-ui/src/lib/components/select/contains-filter.util.spec.ts
@@ -41,8 +41,43 @@ describe('containsFilter', () => {
expect(res).toBeTruthy();
});
- it('should be undefined if value is not string or object', () => {
- const res = containsFilter(1, '1', {});
- expect(res).toBeUndefined();
+ it('should convert number to string and return true when filter matches', () => {
+ const res = containsFilter(123, '123', {});
+ expect(res).toBeTruthy();
+ });
+
+ it('should convert number to string and return true when filter matches partially', () => {
+ const res = containsFilter(123, '12', {});
+ expect(res).toBeTruthy();
+ });
+
+ it('should convert number to string and return false when filter does not match', () => {
+ const res = containsFilter(123, '456', {});
+ expect(res).toBeFalsy();
+ });
+
+ it('should handle number filtering with case sensitive option', () => {
+ const res = containsFilter(123, '123', { filterCaseSensitive: true });
+ expect(res).toBeTruthy();
+ });
+
+ it('should handle alphanumeric string filtering with numbers', () => {
+ const res = containsFilter('ABC123', '123', {});
+ expect(res).toBeTruthy();
+ });
+
+ it('should handle alphanumeric string filtering with partial numbers', () => {
+ const res = containsFilter('ABC123', '12', {});
+ expect(res).toBeTruthy();
+ });
+
+ it('should handle alphanumeric string filtering with letters and numbers', () => {
+ const res = containsFilter('ABC123', 'BC1', {});
+ expect(res).toBeTruthy();
+ });
+
+ it('should return false for alphanumeric string when filter does not match', () => {
+ const res = containsFilter('ABC123', 'XYZ', {});
+ expect(res).toBeFalsy();
});
});
diff --git a/projects/swimlane/ngx-ui/src/lib/components/select/contains-filter.util.ts b/projects/swimlane/ngx-ui/src/lib/components/select/contains-filter.util.ts
index 2d429b99e..0c1aa6ee4 100644
--- a/projects/swimlane/ngx-ui/src/lib/components/select/contains-filter.util.ts
+++ b/projects/swimlane/ngx-ui/src/lib/components/select/contains-filter.util.ts
@@ -9,12 +9,10 @@ export function containsFilter(
if (value === undefined || value === null || depth > 2) {
return false;
}
-
+ if (typeof value === 'number') {
+ value = String(value);
+ }
if (typeof value === 'string') {
- if (!isNaN(+value)) {
- return value === keyword;
- }
-
const escapedKeyword = escapeRegExp(keyword);
// eslint-disable-next-line
const idx = options.filterCaseSensitive ? value.indexOf(keyword) : value.search(new RegExp(escapedKeyword, 'i'));
diff --git a/src/app/forms/selects-page/selects-page.component.html b/src/app/forms/selects-page/selects-page.component.html
index 98dec8a31..38d27a028 100644
--- a/src/app/forms/selects-page/selects-page.component.html
+++ b/src/app/forms/selects-page/selects-page.component.html
@@ -11,14 +11,14 @@
Basic
-
-
+
+
]]>
-
+
@@ -31,35 +31,59 @@ Required
-
-
+
+
]]>
-
+
Filtering
-
+
-
-
+
+
]]>
-
+
+
+
+
+
+
+ Filtering (Numerics)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ]]>
+
@@ -72,29 +96,29 @@ Filtering (Case Sensitive)
-
-
+
+
]]>
-
+
Add New
-
+
-
-
+ Add New
]]>
-
+
@@ -112,7 +136,7 @@ Add New
Long Values
+ [ngModel]="['supercalifragilisticexpialidocioussupercalifragilisticexpialidocioussupercalifragilisticexpialidocious']">
@@ -121,8 +145,8 @@ Long Values
-
-
+
@@ -134,7 +158,7 @@ Long Values
]]>
-
+
@@ -146,8 +170,8 @@ Large ngFor with Default Selections
-
-
+
+
Large ngFor with Default Selections
]]>
-
+
Single select value
-
+
-
-
+
Single select value
]]>
-
+
Input and Option Templates
@@ -197,8 +222,8 @@ Input and Option Templates
-
-
+
+
option.value
@@ -215,7 +240,7 @@ Input and Option Templates
]]>
-
+
@@ -228,14 +253,14 @@ Objects with Grouping
-
-
+
+
]]>
-
+
@@ -255,8 +280,8 @@ Objects with Grouping - with custom template
-
-
+
+
@@ -269,7 +294,7 @@ Objects with Grouping - with custom template
]]>
-
+
@@ -282,14 +307,14 @@ Disabled Options with Placeholder
-
-
+
+
]]>
-
+
@@ -302,14 +327,14 @@ Hidden Disabled Options
-
-
+
+
]]>
-
+
@@ -322,14 +347,14 @@ Disabled Select with Preselected Value
-
-
+
+
]]>
-
+
@@ -342,14 +367,14 @@ Preselected Value as Hidden Option
-
-
+
+
]]>
-
+
@@ -357,10 +382,10 @@ Preselected Value as Hidden Option
No Options
-
-
+
+
]]>
-
+
@@ -368,16 +393,16 @@ No Options
Events
+ (keyup)="onEvent('ngx-select change', $event)" (toggle)="onEvent('ngx-select toggle', $event)">
-
-
+
+
]]>
-
+
@@ -385,7 +410,7 @@ Events
Customization
+ [selectCaret]="doubleDown">
@@ -395,8 +420,8 @@ Customization
-
-
+ Customization
]]>
-
+
-
-
-
+
+
+
- Select Options with Tooltip
-
- Select Options with Tooltip
+
+
-
+
-
+
-
-
-
+
+
+ Select Options with Tooltip
}"
>
]]>
-
+
@@ -493,7 +506,8 @@ Enabled state can be changed using reactive forms
-
@@ -666,43 +682,39 @@ No Options
-
-
+
+
]]>
-
+
-
-
-
-
-
+
+
+
+
+
]]>
-
+
-
+
@@ -720,13 +732,13 @@ No Options
+ value="Really long option to show autosize of the component when autosize is selected">
-
+
@@ -743,7 +755,7 @@ No Options
+ autosize="true">
@@ -760,13 +772,13 @@ No Options
+ autosize="true">
+ autosize="true">
@@ -790,171 +802,172 @@ No Options
With Value |
-
-
-
-
- |
+
+
+
+
+ |
-
-
-
- |
+
+
+
+
Disabled Dropdown |
-
-
-
-
- |
-
-
-
-
- |
+
+
+
+
+ |
+
+
+
+
+ |
Required |
-
-
-
- |
+
+
+
+
-
-
-
- |
+
+
+
+
Empty w/o Placeholder |
-
-
-
- |
+
+
+
+
-
-
-
- |
+
+
+
+
Empty w/ Placeholder |
-
-
-
- |
-
-
-
-
- |
+
+
+
+
+
+
+
+
+ |
Multiple |
-
-
-
-
- |
-
-
-
-
- |
+
+
+
+
+ |
+
+
+
+
+ |
Tagging |
-
- |
-
- |
+
+ |
+
+ |
Empty Tagging w/o Placeholder |
-
- |
-
- |
+
+ |
+
+ |
Empty Tagging w/ Placeholder |
-
- |
-
- |
+
+ |
+
+ |
Select With Links |
-
-
-
-
-
- {{ option }}
-
-
-
- |
-
-
-
-
-
- {{ option }}
-
-
-
- |
+
+
+
+
+
+ {{ option }}
+
+
+
+ |
+
+
+
+
+
+ {{ option }}
+
+
+
+ |
Tagging With Links |
-
-
-
-
-
- {{ option }}
-
-
-
- |
-
-
-
-
-
- {{ option }}
-
-
-
- |
+
+
+
+
+
+ {{ option }}
+
+
+
+ |
+
+
+
+
+
+ {{ option }}
+
+
+
+ |
Tagging With Long Values |
-
- |
-
- |
+
+ |
+
+ |
Grouping |
@@ -1097,7 +1110,8 @@
@Input()
filterEmptyPlaceholder: string = 'No matches...'
- Placeholder to display when the component has no selectable options that match the user's filter term. |
+ Placeholder to display when the component has no selectable options that match the user's filter term.
+ |
@@ -1216,7 +1230,8 @@
@Input()
selectCaret: string
|
- Accepts string or template reference. The select caret to display in place of the default caret, typically an icon. |
+ Accepts string or template reference. The select caret to display in place
+ of the default caret, typically an icon. |
@@ -1318,5 +1333,4 @@ |