Просмотр исходного кода

Merge branch 'develop' into feature

jeremystretch 3 лет назад
Родитель
Сommit
15005209d1

+ 1 - 0
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
 

+ 2 - 2
netbox/templates/base/layout.html

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

+ 1 - 1
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 }}"
   />
 
   <input name="obj_type" hidden type="text" class="search-obj-type" />

+ 5 - 2
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,
+    }