From 9a27c7ae208e06715b276ceec0c50e5f5767aab5 Mon Sep 17 00:00:00 2001 From: Franciszek Stachura Date: Wed, 11 Sep 2024 13:56:04 +0200 Subject: [PATCH] autocomplete: Submit form on item selection --- static/autocomplete.js | 5 +++++ templates/layout.html | 2 +- templates/topbar.html | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/static/autocomplete.js b/static/autocomplete.js index bb7bdc5..08b0378 100644 --- a/static/autocomplete.js +++ b/static/autocomplete.js @@ -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 diff --git a/templates/layout.html b/templates/layout.html index cab295b..1aa4a25 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -16,7 +16,7 @@ - +