sa-si-dev / virtual-select

A javascript plugin for dropdown with virtual scroll

Home Page:https://sa-si-dev.github.io/virtual-select

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Options markSearchResults and labelRenderer does not play well together

neonrust opened this issue · comments

Having a labelRenderer that adds HTML, causes the markSearchResults feature to mark text maching DOM elements. That is, if you search for something that matches it, e.g. "class", that also happens to match an option.

I looked in the code, and the marking does indeed operate on the label generated by the labelRenderer.

      if (hasLabelRenderer) {
        optionLabel = labelRenderer(d);
      } else {
        optionLabel = d.label;
      }

      if (d.description) {
        description = `<div class="vscomp-option-description" ${optionTooltip}>${d.description}</div>`;
      }

      if (d.isCurrentNew) {
        optionClasses += ' current-new';
        rightSection += newOptionIconHtml;
      } else if (markSearchResults && (!d.isGroupTitle || searchGroup)) {
        optionLabel = optionLabel.replace(searchRegex, '<mark>$1</mark>');
      }

@neonrust this issue has been fixed in the release v1.0.38. Thanks for the contribution