Merge pull request #23038 from shuuji3/en/place-default-search-keywords
Retain the current search keywords in the search input form
This commit is contained in:
commit
35650aa48f
|
@ -17,6 +17,15 @@ limitations under the License.
|
||||||
var Search = {
|
var Search = {
|
||||||
init: function () {
|
init: function () {
|
||||||
$(document).ready(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) {
|
$(document).on("keypress", ".td-search-input", function (e) {
|
||||||
if (e.keyCode !== 13) {
|
if (e.keyCode !== 13) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue