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:
@@ -24,8 +24,10 @@ class AutocompleteComponent < ApplicationComponent
|
|||||||
def highlight_antecedent(result)
|
def highlight_antecedent(result)
|
||||||
if result.type == "tag-word"
|
if result.type == "tag-word"
|
||||||
highlight_matching_words(result.antecedent, query)
|
highlight_matching_words(result.antecedent, query)
|
||||||
else
|
elsif query.include?("*")
|
||||||
highlight_wildcard_match(result.antecedent, query)
|
highlight_wildcard_match(result.antecedent, query)
|
||||||
|
else
|
||||||
|
highlight_wildcard_match(result.antecedent, query + "*")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -38,8 +40,10 @@ class AutocompleteComponent < ApplicationComponent
|
|||||||
highlight_wildcard_match(result.label, "*" + metatag.value + "*")
|
highlight_wildcard_match(result.label, "*" + metatag.value + "*")
|
||||||
elsif metatag.present?
|
elsif metatag.present?
|
||||||
highlight_wildcard_match(result.label, metatag.value + "*")
|
highlight_wildcard_match(result.label, metatag.value + "*")
|
||||||
else
|
elsif query.include?("*")
|
||||||
highlight_wildcard_match(result.value, query)
|
highlight_wildcard_match(result.value, query)
|
||||||
|
else
|
||||||
|
highlight_wildcard_match(result.value, query + "*")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user