Skip to content

Commit

Permalink
fix(datagrid): reject strings in the numeric property filter when active
Browse files Browse the repository at this point in the history
This is a backport of 6973559.
  • Loading branch information
derkoe authored and kevinbuhmann committed Aug 22, 2022
1 parent 0db3363 commit 8d1faba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Expand Up @@ -21,10 +21,10 @@ export default function (): void {
expect(this.filter.accepts({ a: 'not a number' }, null, null)).toBe(true);
});

// it('rejects strings when active', function () {
// this.filter = new DatagridPropertyNumericFilter('a');
// expect(this.filter.accepts({ a: 'not a number' }, null, 1)).toBe(false);
// });
it('rejects strings when active', function () {
this.filter = new DatagridPropertyNumericFilter('a');
expect(this.filter.accepts({ a: 'not a number' }, null, 1)).toBe(false);
});

it('always rejects undefined', function () {
this.filter = new DatagridPropertyNumericFilter('a');
Expand Down
Expand Up @@ -19,10 +19,10 @@ export class DatagridPropertyNumericFilter<T = any> implements ClrDatagridNumeri
if (propValue === undefined) {
return false;
}
if (low !== null && propValue < low) {
if (low !== null && (typeof propValue !== 'number' || propValue < low)) {
return false;
}
if (high !== null && propValue > high) {
if (high !== null && (typeof propValue !== 'number' || propValue > high)) {
return false;
}
return true;
Expand Down

0 comments on commit 8d1faba

Please sign in to comment.