Skip to content

Commit

Permalink
Typeahead dismissal fix (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelkornblum authored Nov 24, 2023
1 parent 070109c commit 51c1b2d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/search/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ def search(self, query, *args, **kwargs):
return self._wagtail_search(queryset, query, *args, **kwargs)

def autocomplete(self, query, *args, **kwargs):
return self._wagtail_autocomplete(self.get_queryset(), query, *args, **kwargs)
# never show inactive profiles on autocomplete
queryset = Person.objects.all().active()
return self._wagtail_autocomplete(queryset, query, *args, **kwargs)


class TeamsSearchVector(SearchVector):
Expand Down
6 changes: 4 additions & 2 deletions src/search/templates/search/partials/search_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
placeholder="{{ placeholder|default:'Search site' }}"
type="search"
value="{{ search_query|default:'' }}"
hx-trigger="keyup changed delay:250ms"
hx-trigger="input keyup changed delay:150ms"
hx-get="{% url 'search:autocomplete' %}"
hx-target="#autocomplete-results">
hx-target="#autocomplete-results"
onblur="document.getElementById('autocomplete-results').style.display='none'"
onfocus="document.getElementById('autocomplete-results').style.display='block'">
<button type="submit">Search</button>
<div id="autocomplete-results" class="autocomplete-overlay"></div>
</form>

0 comments on commit 51c1b2d

Please sign in to comment.