include query item in search suggestions (#117)
but only if it does not end with ".", since items with "." are partial names only used to drill down to the actual package/option name. when there is one result in suggestions and is the same as query we don't show results
This commit is contained in:
parent
af66eef748
commit
08c5d997dc
|
@ -641,10 +641,30 @@ getSuggestions query querySuggest =
|
||||||
in
|
in
|
||||||
case querySuggest of
|
case querySuggest of
|
||||||
RemoteData.Success result ->
|
RemoteData.Success result ->
|
||||||
result.suggest
|
let
|
||||||
|> maybeList (\x -> x.query |> maybeList (List.map .options))
|
suggestions =
|
||||||
|> List.concat
|
result.suggest
|
||||||
|> List.filter (\x -> x.text /= query)
|
|> maybeList (\x -> x.query |> maybeList (List.map .options))
|
||||||
|
|> List.concat
|
||||||
|
|> List.filter
|
||||||
|
(\x ->
|
||||||
|
if String.endsWith "." (Maybe.withDefault "" query) then
|
||||||
|
x.text /= query
|
||||||
|
|
||||||
|
else
|
||||||
|
True
|
||||||
|
)
|
||||||
|
|
||||||
|
firstItemText items =
|
||||||
|
items
|
||||||
|
|> List.head
|
||||||
|
|> Maybe.andThen .text
|
||||||
|
in
|
||||||
|
if List.length suggestions == 1 && firstItemText suggestions == query then
|
||||||
|
[]
|
||||||
|
|
||||||
|
else
|
||||||
|
suggestions
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
[]
|
[]
|
||||||
|
|
Loading…
Reference in a new issue