Retain other query params in header search behaviour

pull/8909/head
Sage Abdullah 2022-07-15 20:02:50 +07:00 zatwierdzone przez Karl Hobley
rodzic 4bedf6e045
commit 5a957a629a
2 zmienionych plików z 10 dodań i 3 usunięć

Wyświetl plik

@ -83,6 +83,7 @@ Changelog
* Add HTML-aware max_length validation on RichTextField and RichTextBlock (Matt Westcott)
* Remove undocumented `SearchableListMixin` (Sage Abdullah)
* Extract filtering code from ReportView to generic IndexView (Sage Abdullah)
* Retain other query params in header search behaviour (Sage Abdullah)
* Fix: Typo in `ResumeWorkflowActionFormatter` message (Stefan Hammer)
* Fix: Throw a meaningful error when saving an image to an unrecognised image format (Christian Franke)
* Fix: Remove extra padding for headers with breadcrumbs on mobile viewport (Steven Steinwand)

Wyświetl plik

@ -318,15 +318,21 @@ $(() => {
$inputContainer.addClass(workingClasses);
searchNextIndex++;
const index = searchNextIndex;
// Update q, reset to first page, and keep other query params
const searchParams = new URLSearchParams(window.location.search);
searchParams.set('q', newQuery);
searchParams.delete('p');
const queryString = searchParams.toString();
$.ajax({
url: window.headerSearch.url,
// eslint-disable-next-line id-length
data: { q: newQuery },
data: queryString,
success(data) {
if (index > searchCurrentIndex) {
searchCurrentIndex = index;
$(window.headerSearch.targetOutput).html(data).slideDown(800);
window.history.replaceState(null, null, '?q=' + newQuery);
window.history.replaceState(null, null, '?' + queryString);
$input[0].dispatchEvent(new Event('search-success'));
}
},