Case-independent tags dropdown view

This commit is contained in:
Cohee 2023-09-06 01:47:55 +03:00
parent 05215218d9
commit f5beae517e
1 changed files with 2 additions and 2 deletions

View File

@ -170,7 +170,7 @@ function removeTagFromMap(tagId) {
function findTag(request, resolve, listSelector) { function findTag(request, resolve, listSelector) {
const skipIds = [...($(listSelector).find(".tag").map((_, el) => $(el).attr("id")))]; const skipIds = [...($(listSelector).find(".tag").map((_, el) => $(el).attr("id")))];
const haystack = tags.filter(t => !skipIds.includes(t.id)).map(t => t.name).sort(); const haystack = tags.filter(t => !skipIds.includes(t.id)).map(t => t.name).sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
const needle = request.term.toLowerCase(); const needle = request.term.toLowerCase();
const hasExactMatch = haystack.findIndex(x => x.toLowerCase() == needle) !== -1; const hasExactMatch = haystack.findIndex(x => x.toLowerCase() == needle) !== -1;
const result = haystack.filter(x => x.toLowerCase().includes(needle)); const result = haystack.filter(x => x.toLowerCase().includes(needle));