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;