autocomplete: fix highlighting of short searches.

Fix a bug where tags weren't highlighted correctly when the search only contained one character.
This commit is contained in:
evazion
2022-09-02 14:13:16 -05:00
parent 6235965da0
commit f20e1d5bc9

View File

@@ -24,8 +24,10 @@ class AutocompleteComponent < ApplicationComponent
def highlight_antecedent(result)
if result.type == "tag-word"
highlight_matching_words(result.antecedent, query)
else
elsif query.include?("*")
highlight_wildcard_match(result.antecedent, query)
else
highlight_wildcard_match(result.antecedent, query + "*")
end
end
@@ -38,8 +40,10 @@ class AutocompleteComponent < ApplicationComponent
highlight_wildcard_match(result.label, "*" + metatag.value + "*")
elsif metatag.present?
highlight_wildcard_match(result.label, metatag.value + "*")
else
elsif query.include?("*")
highlight_wildcard_match(result.value, query)
else
highlight_wildcard_match(result.value, query + "*")
end
end