Clear search input on submission
This commit is contained in:
parent
40d3053df9
commit
c6b07852fe
2 changed files with 10 additions and 0 deletions
|
@ -846,6 +846,7 @@ Preview:
|
|||
| <kbd>Enter</kbd> | Perform search in the same tab | Search input is focused and not empty |
|
||||
| <kbd>Ctrl</kbd> + <kbd>Enter</kbd> | Perform search in a new tab | Search input is focused and not empty |
|
||||
| <kbd>Escape</kbd> | Leave focus | Search input is focused |
|
||||
| <kbd>Up</kbd> | Insert the last search query since the page was opened into the input field | Search input is focused |
|
||||
|
||||
> [!TIP]
|
||||
>
|
||||
|
|
|
@ -105,6 +105,7 @@ function setupSearchBoxes() {
|
|||
const bangsMap = {};
|
||||
const kbdElement = widget.getElementsByTagName("kbd")[0];
|
||||
let currentBang = null;
|
||||
let lastQuery = "";
|
||||
|
||||
for (let j = 0; j < bangs.length; j++) {
|
||||
const bang = bangs[j];
|
||||
|
@ -141,6 +142,14 @@ function setupSearchBoxes() {
|
|||
window.location.href = url;
|
||||
}
|
||||
|
||||
lastQuery = query;
|
||||
inputElement.value = "";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.key == "ArrowUp" && lastQuery.length > 0) {
|
||||
inputElement.value = lastQuery;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue