feat: Improve community search functionality in CommunityAutocomplete by refining matching logic for partial values and colon-separated entries, enhancing user experience in filtering.
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 2m2s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 2m2s
This commit is contained in:
@@ -87,14 +87,25 @@ function CommunityAutocomplete({ label, value, onChange, communities = [], requi
|
||||
const search = inputValue.toLowerCase().trim();
|
||||
if (!search) return true;
|
||||
|
||||
const cValue = (c.value || '').toLowerCase();
|
||||
|
||||
// Поиск по полному значению
|
||||
if (c.value && c.value.toLowerCase().includes(search)) return true;
|
||||
if (cValue.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 (cValue.includes(':')) {
|
||||
const parts = cValue.split(':');
|
||||
if (parts[1] && parts[1].includes(search)) return true;
|
||||
if (parts[0] && parts[0].includes(search)) return true;
|
||||
}
|
||||
|
||||
// Обратный поиск: "65001:120" найдёт "120" в справочнике
|
||||
if (search.includes(':')) {
|
||||
const searchParts = search.split(':');
|
||||
// Если в справочнике просто число, проверяем совпадение с частью после двоеточия
|
||||
if (searchParts[1] && cValue === searchParts[1]) return true;
|
||||
// Также проверяем частичное совпадение
|
||||
if (searchParts[1] && cValue.includes(searchParts[1])) return true;
|
||||
}
|
||||
|
||||
// Поиск по названию и описанию
|
||||
|
||||
Reference in New Issue
Block a user