From 0da04232f3fba9abee90fe83ff05e18eaa972038 Mon Sep 17 00:00:00 2001 From: PieterL75 <74899468+PieterL75@users.noreply.github.com> Date: Fri, 18 Mar 2022 18:23:39 +0100 Subject: [PATCH 1/2] Fixes #8813 Retain search value after submitting (#8907) * Fixes #8813 Retain search value after submitting * remove autofocus from searchbar Co-authored-by: Pieter Lambrecht --- netbox/templates/base/layout.html | 4 ++-- netbox/utilities/templates/search/searchbar.html | 2 +- netbox/utilities/templatetags/search.py | 7 +++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/netbox/templates/base/layout.html b/netbox/templates/base/layout.html index da2d10c65..0def1c90e 100644 --- a/netbox/templates/base/layout.html +++ b/netbox/templates/base/layout.html @@ -33,7 +33,7 @@
- {% search_options %} + {% search_options request %}
@@ -45,7 +45,7 @@ {# 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, + } From f64987d0c4ddef473f997bfa71c8bca3d6adbf09 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Fri, 18 Mar 2022 13:25:47 -0400 Subject: [PATCH 2/2] Changelog for #8813 --- docs/release-notes/version-3.1.md | 1 + 1 file changed, 1 insertion(+) 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