feat: Enhance community filtering logic in CommunityAutocomplete to support partial matches and improved search capabilities, including handling values with colons.
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 2m5s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 2m5s
This commit is contained in:
@@ -84,12 +84,24 @@ function CommunityAutocomplete({ label, value, onChange, communities = [], requi
|
||||
|
||||
// Фильтруем communities по введённому тексту
|
||||
const filteredCommunities = communities.filter(c => {
|
||||
const search = inputValue.toLowerCase();
|
||||
return (
|
||||
(c.value && c.value.toLowerCase().includes(search)) ||
|
||||
(c.name && c.name.toLowerCase().includes(search)) ||
|
||||
(c.description && c.description.toLowerCase().includes(search))
|
||||
);
|
||||
const search = inputValue.toLowerCase().trim();
|
||||
if (!search) return true;
|
||||
|
||||
// Поиск по полному значению
|
||||
if (c.value && c.value.toLowerCase().includes(search)) return true;
|
||||
|
||||
// Поиск по части после двоеточия (например, "120" найдёт "65001:120")
|
||||
if (c.value && c.value.includes(':')) {
|
||||
const parts = c.value.split(':');
|
||||
if (parts[1] && parts[1].toLowerCase().includes(search)) return true;
|
||||
if (parts[0] && parts[0].toLowerCase().includes(search)) return true;
|
||||
}
|
||||
|
||||
// Поиск по названию и описанию
|
||||
if (c.name && c.name.toLowerCase().includes(search)) return true;
|
||||
if (c.description && c.description.toLowerCase().includes(search)) return true;
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user