diff --git a/netbox/templates/base/layout.html b/netbox/templates/base/layout.html
index 0def1c90e..7e5e45da1 100644
--- a/netbox/templates/base/layout.html
+++ b/netbox/templates/base/layout.html
@@ -33,7 +33,7 @@
- {% search_options request %}
+ {% search_options request "mobile" %}
@@ -45,7 +45,7 @@
{# Search bar #}
- {% search_options request %}
+ {% search_options request "desktop" %}
{# Proflie/login button #}
diff --git a/netbox/utilities/templates/search/searchbar.html b/netbox/utilities/templates/search/searchbar.html
index 0335160e7..78d095e24 100644
--- a/netbox/utilities/templates/search/searchbar.html
+++ b/netbox/utilities/templates/search/searchbar.html
@@ -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 %}
/>
diff --git a/netbox/utilities/templatetags/search.py b/netbox/utilities/templatetags/search.py
index 5726ae5d5..1b7aacc2a 100644
--- a/netbox/utilities/templatetags/search.py
+++ b/netbox/utilities/templatetags/search.py
@@ -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,
}