Skip to content

Commit 35650aa

Browse files
authored
Merge pull request #23038 from shuuji3/en/place-default-search-keywords
Retain the current search keywords in the search input form
2 parents 968e568 + 34d805d commit 35650aa

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

assets/js/search.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ limitations under the License.
1717
var Search = {
1818
init: function () {
1919
$(document).ready(function () {
20+
// Fill the search input form with the current search keywords
21+
const searchKeywords = new URLSearchParams(location.search).get('q');
22+
if (searchKeywords !== null && searchKeywords !== '') {
23+
const searchInput = document.querySelector('.td-search-input');
24+
searchInput.focus();
25+
searchInput.value = searchKeywords;
26+
}
27+
28+
// Set a keydown event
2029
$(document).on("keypress", ".td-search-input", function (e) {
2130
if (e.keyCode !== 13) {
2231
return;

0 commit comments

Comments
 (0)