Skip to content

Commit

Permalink
Merge pull request #36 from Kazmin87/patch-1
Browse files Browse the repository at this point in the history
Fix highlight for labels which does not contains lookup
  • Loading branch information
lekoala authored Oct 27, 2023
2 parents 7c5903c + 6eeccbe commit 451da07
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -806,10 +806,12 @@ class Autocomplete {

if (this._config.highlightTyped) {
const idx = normalize(label).indexOf(lookup);
label =
label.substring(0, idx) +
`<mark class="${this._config.highlightClass}">${label.substring(idx, idx + lookup.length)}</mark>` +
label.substring(idx + lookup.length, label.length);
if(idx !== -1){
label =
label.substring(0, idx) +
`<mark class="${this._config.highlightClass}">${label.substring(idx, idx + lookup.length)}</mark>` +
label.substring(idx + lookup.length, label.length);
}
}

label = this._config.onRenderItem(item, label, this);
Expand Down

0 comments on commit 451da07

Please sign in to comment.