This commit is contained in:
anna-dingler 2024-05-07 11:38:21 -07:00 коммит произвёл GitHub
Родитель 1bb9994d87
Коммит e946c140e3
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 31 добавлений и 1 удалений

Просмотреть файл

@ -4911,7 +4911,37 @@ export class FilteredChoiceSet {
const choice = document.createElement("span");
choice.className = this.hostConfig.makeCssClassName("ac-input", "ac-choiceSetInput-choice");
choice.id = `ac-choiceSetInput-${this._choiceSetId}-choice-${id}`;
choice.innerHTML = value.replace(filter, `<b>${filter}</b>`);
const startIndex = value.indexOf(filter);
if (startIndex === -1) {
// Filter wasn't found, add the value as is
const valueSpan = document.createElement("span");
valueSpan.innerText = value;
choice.appendChild(valueSpan);
} else {
if (startIndex > 0) {
// Add a span with the beginning unmatched text
const unmatchedBeg = value.substring(0, startIndex);
const unmatchedBegSpan = document.createElement("span");
unmatchedBegSpan.innerText = unmatchedBeg;
choice.appendChild(unmatchedBegSpan);
}
// Add the matched filter with bold styling
const filterSpan = document.createElement("span");
filterSpan.innerText = filter;
filterSpan.style.fontWeight = "bold";
choice.appendChild(filterSpan);
if (startIndex + filter.length < value.length) {
// Add a span with the ending unmatched text
const unmatchedEnd = value.substring(startIndex + filter.length);
const unmatchedEndSpan = document.createElement("span");
unmatchedEndSpan.innerText = unmatchedEnd;
choice.appendChild(unmatchedEndSpan);
}
}
choice.tabIndex = -1;
choice.onclick = () => {