diff --git a/docs/release-notes/version-3.1.md b/docs/release-notes/version-3.1.md index 6279a109f..9e6d8ad96 100644 --- a/docs/release-notes/version-3.1.md +++ b/docs/release-notes/version-3.1.md @@ -11,6 +11,7 @@ ### Bug Fixes +* [#8813](https://github.com/netbox-community/netbox/issues/8813) - Retain global search bar query after submitting * [#8820](https://github.com/netbox-community/netbox/issues/8820) - Fix navbar background color in dark mode * [#8850](https://github.com/netbox-community/netbox/issues/8850) - Show airflow field on device REST API serializer when config context data is included diff --git a/netbox/templates/base/layout.html b/netbox/templates/base/layout.html index ef7015008..dd0412eac 100644 --- a/netbox/templates/base/layout.html +++ b/netbox/templates/base/layout.html @@ -41,7 +41,7 @@ Blocks:
- {% search_options %} + {% search_options request %}
@@ -53,7 +53,7 @@ Blocks: {# Search bar #}
- {% search_options %} + {% search_options request %}
{# Proflie/login button #} diff --git a/netbox/utilities/templates/search/searchbar.html b/netbox/utilities/templates/search/searchbar.html index d71fd8e69..74d12e9b9 100644 --- a/netbox/utilities/templates/search/searchbar.html +++ b/netbox/utilities/templates/search/searchbar.html @@ -5,7 +5,7 @@ aria-label="Search" placeholder="Search" class="form-control" - value="{{ request.GET.q }}" + value="{{ request.GET.q|escape }}" /> diff --git a/netbox/utilities/templatetags/search.py b/netbox/utilities/templatetags/search.py index aad533e7e..5726ae5d5 100644 --- a/netbox/utilities/templatetags/search.py +++ b/netbox/utilities/templatetags/search.py @@ -8,6 +8,9 @@ search_form = SearchForm() @register.inclusion_tag("search/searchbar.html") -def search_options() -> Dict: +def search_options(request) -> Dict: """Provide search options to template.""" - return {"options": search_form.options} + return { + 'options': search_form.options, + 'request': request, + }