Skip to content

Commit

Permalink
Merge pull request #2513 from smeup/fix/filter-with-empty-string
Browse files Browse the repository at this point in the history
LS25000885: Filter with empty filter value
  • Loading branch information
pasere-smeup authored Feb 18, 2025
2 parents 0119083 + a5f46d4 commit 2ec3cf3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion packages/ketchup/src/utils/filters/filters-column-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ export class FiltersColumnMenu extends Filters {
column: string,
remFilter: string
): void {
if (!filters || !remFilter || !filters[column]) {
// if remFilter is '' it is a perfectly fine value, explicitly target undefined value
if (!filters || remFilter == undefined || !filters[column]) {
return;
}

Expand Down
20 changes: 12 additions & 8 deletions packages/ketchup/src/utils/filters/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,18 @@ export class Filters {
// Split multiple filters and trim each one
const filters = filterValue.split(';').map((f) => f.trim());
// All filters must match (AND condition)
return filters.every(
(filter) =>
value.toLowerCase().includes(filter.toLowerCase()) ||
this.matchSpecialFilter(
value.toLowerCase(),
filter.toLowerCase().match(FILTER_ANALYZER)
)
);
return filters.every((filter) => {
// if filter is '' it should be excluded since it is always included in every possible string and thus always leading to a match!
const valueIncludesFilter =
value.toLowerCase().includes(filter.toLowerCase()) &&
filter !== '';
const valueMatchesSpecialFilter = this.matchSpecialFilter(
value.toLowerCase(),
filter.toLowerCase().match(FILTER_ANALYZER)
);

return valueIncludesFilter || valueMatchesSpecialFilter;
});
}

/**
Expand Down

0 comments on commit 2ec3cf3

Please sign in to comment.