mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Improve service filtering (#19811)
* Improve service filtering Split filter term by space and match if each word is individually present * Prettier formatting * Fix un-necessary toLowerCase() call Co-authored-by: karwosts <32912880+karwosts@users.noreply.github.com> * Combine filter check conditions into the same loop * Prettier formatting --------- Co-authored-by: karwosts <32912880+karwosts@users.noreply.github.com>
This commit is contained in:
parent
83190c21db
commit
401bbed67b
@ -114,11 +114,14 @@ class HaServicePicker extends LitElement {
|
|||||||
if (!filter) {
|
if (!filter) {
|
||||||
return processedServices;
|
return processedServices;
|
||||||
}
|
}
|
||||||
return processedServices.filter(
|
const split_filter = filter.split(" ");
|
||||||
(service) =>
|
return processedServices.filter((service) => {
|
||||||
service.service.toLowerCase().includes(filter) ||
|
const lower_service_name = service.name.toLowerCase();
|
||||||
service.name?.toLowerCase().includes(filter)
|
const lower_service = service.service.toLowerCase();
|
||||||
);
|
return split_filter.every(
|
||||||
|
(f) => lower_service_name.includes(f) || lower_service.includes(f)
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user