Plugin List: Apply search filter if prefilled by browser (#6543)

* Plugin List: Apply searchfilter if prefilled by browser

Browsers often prefill the form fields, e.g. with their old content when reloading or going back from the previous page. However these filters were not applied until you changed one of the form fields

* Fix linting errors in plugins.js

* Apply review suggestions
This commit is contained in:
pajowu
2026-09-29 11:51:29 +02:00
committed by GitHub
parent 43e5b62db3
commit 3440ee16f2
2 changed files with 6 additions and 6 deletions
-1
View File
@@ -49,7 +49,6 @@ const ignores = globalIgnores([
'src/pretix/static/pretixcontrol/js/ui/editor.js',
'src/pretix/static/pretixcontrol/js/ui/geo.js',
'src/pretix/static/pretixcontrol/js/ui/main.js',
'src/pretix/static/pretixcontrol/js/ui/plugins.js',
'src/pretix/static/pretixcontrol/js/ui/subevent.js',
'src/pretix/static/pretixcontrol/js/ui/variations.js',
'src/pretix/static/pretixcontrol/js/ui/webauthn.js',
@@ -67,8 +67,8 @@ $(function () {
continue
matches.push([rank, plugin])
}
matches.sort(function (a, b) { return (b[0] - a[0]) || strcmp(a[1].sortName, b[1].sortName) })
$results.append(matches.map(function (res) { return $(res[1].html).prepend('<span class="pull-right">' + res[1].categoryLabel + '</span>') }))
matches.sort((a, b) => ((b[0] - a[0]) || strcmp(a[1].sortName, b[1].sortName)))
$results.append(matches.map((res) => $(res[1].html).prepend('<span class="pull-right">' + res[1].categoryLabel + '</span>')))
$results.find('.panel-body, .panel, .featured-plugin, .btn-lg').removeClass('panel-body panel featured-plugin btn-lg')
if (matches.length === 0) {
$results.append(gettext('No results'))
@@ -81,9 +81,10 @@ $(function () {
$('#plugin_search_input').val('').trigger('input')
})
if (location.search) {
var search = new URLSearchParams(location.search)
if (search.has('q')) {
$('#plugin_search_input').val(search.get('q')).trigger('input')
const search_params = new URLSearchParams(location.search)
if (search_params.has('q')) {
$('#plugin_search_input').val(search_params.get('q'))
}
}
search() // if pre-filled by browser (e.g. after reload)
})