Only autofocus on desktop navbar

This commit is contained in:
Pieter Lambrecht 2022-03-29 10:56:40 +02:00
parent 5063129979
commit b13f03e0c6
3 changed files with 8 additions and 7 deletions

View File

@ -33,7 +33,7 @@
</button>
</div>
<div class="d-flex my-1 flex-grow-1 justify-content-center w-100">
{% search_options request %}
{% search_options request "mobile" %}
</div>
</div>
@ -45,7 +45,7 @@
{# Search bar #}
<div class="col-6 d-flex flex-grow-1 justify-content-center">
{% search_options request %}
{% search_options request "desktop" %}
</div>
{# Proflie/login button #}

View File

@ -5,10 +5,10 @@
aria-label="Search"
placeholder="Search"
class="form-control"
value=""
{% if request.GET.q %}
autofocus
onfocus="this.value = '{{ request.GET.q|escapejs }}';"
{% if navbar == "mobile" %}
value="{{ request.GET.q|escape }}"
{% else %}
value="" autofocus onfocus="this.value = '{{ request.GET.q|escapejs }}';"
{% endif %}
/>

View File

@ -8,9 +8,10 @@ search_form = SearchForm()
@register.inclusion_tag("search/searchbar.html")
def search_options(request) -> Dict:
def search_options(request, navbar) -> Dict:
"""Provide search options to template."""
return {
'options': search_form.options,
'request': request,
'navbar' : navbar,
}