From 34d805df7280f40c93a3c832f117caa7ec964c76 Mon Sep 17 00:00:00 2001 From: TAKAHASHI Shuuji Date: Sun, 9 Aug 2020 12:14:40 +0900 Subject: [PATCH] Fill the search input form with the current search keywords. --- assets/js/search.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/assets/js/search.js b/assets/js/search.js index 3d6e9d9447..eeecf9c60a 100644 --- a/assets/js/search.js +++ b/assets/js/search.js @@ -17,6 +17,15 @@ limitations under the License. var Search = { init: function () { $(document).ready(function () { + // Fill the search input form with the current search keywords + const searchKeywords = new URLSearchParams(location.search).get('q'); + if (searchKeywords !== null && searchKeywords !== '') { + const searchInput = document.querySelector('.td-search-input'); + searchInput.focus(); + searchInput.value = searchKeywords; + } + + // Set a keydown event $(document).on("keypress", ".td-search-input", function (e) { if (e.keyCode !== 13) { return;