Skip to content

Commit

Permalink
Improve service filtering
Browse files Browse the repository at this point in the history
Split filter term by space and match if each word is individually present
  • Loading branch information
malkstar committed Feb 15, 2024
1 parent 8136cc8 commit 1baf2dc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/components/ha-service-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,13 @@ class HaServicePicker extends LitElement {
if (!filter) {
return processedServices;
}
const split_filter = filter.split(' ')
return processedServices.filter(
(service) =>
service.service.toLowerCase().includes(filter) ||
service.name?.toLowerCase().includes(filter)
(service) => {
const lower_service_name = service.name.toLowerCase();
const lower_service = service.service.toLowerCase();
return split_filter.every(f => lower_service_name.includes(f)) || split_filter.every(f => lower_service.toLowerCase().includes(f))
}
);
}
);
Expand Down

0 comments on commit 1baf2dc

Please sign in to comment.