autocomplete: Submit form on item selection

This commit is contained in:
Franciszek Stachura 2024-09-11 13:56:04 +02:00 committed by Théo Lebrun
parent 713401cf95
commit 9a27c7ae20
3 changed files with 7 additions and 2 deletions

View file

@ -24,6 +24,7 @@ AutoComplete({
Limit: 10,
MinChars: 4,
Delay: 500,
SelectCallback: _ => document.getElementById("search-form").requestSubmit(),
}, "#search-input");
},{"autocomplete-js":2}],2:[function(require,module,exports){
@ -242,6 +243,7 @@ var AutoComplete = /** @class */ (function () {
HttpMethod: "GET",
QueryArg: "q",
Url: null,
SelectCallback: null,
KeyboardMappings: {
"Enter": {
Conditions: [{
@ -564,6 +566,9 @@ var AutoComplete = /** @class */ (function () {
this.Input.value = item.innerHTML;
}
this.Input.setAttribute("data-autocomplete-old-value", this.Input.value);
if (this.SelectCallback) {
this.SelectCallback();
}
},
/**
* Handle HTTP error on the request

View file

@ -16,7 +16,7 @@
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1" />
<link rel="stylesheet" href="/static/style.css?v=9">
<link rel="stylesheet" href="/static/banner.css">
<link rel="stylesheet" href="/static/autocomplete.css">
<link rel="stylesheet" href="/static/autocomplete.css?v=2">
<script>
document.documentElement.classList.remove('no-js');
document.documentElement.classList.add('js');

View file

@ -8,7 +8,7 @@
{% endfor %}
</div>
<div class="search">
<form method="post" action="{{ ident_base_url }}">
<form method="post" action="{{ ident_base_url }}" id="search-form">
<select name="f" title="Restricts search to specific file families">
{% for id, description in topbar_families.items() %}
<option value="{{ id }}" {{ 'selected' if (current_family == id or current_family is not defined) else '' }}>