mirror of
https://github.com/ziglang/zig.git
synced 2026-02-15 22:09:49 +00:00
feat: make modal more restrictive and more Esc freedom
This makes it so that you can no longer interact with the search bar or the results or anything while the modal is open. That's why it's a "modal" and not a "dialog". It also makes it so that you can now always press Esc to return to the results or the main page. Previously this was only possible when the search field was active.
This commit is contained in:
parent
9900413eb1
commit
8f6f4bc7ca
@ -3148,6 +3148,22 @@ var zigAnalysis;
|
||||
domSearch.blur();
|
||||
}
|
||||
|
||||
function onEscape(ev) {
|
||||
if (!domHelpModal.classList.contains("hidden")) {
|
||||
domHelpModal.classList.add("hidden");
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
} else {
|
||||
domSearch.value = "";
|
||||
domSearch.blur();
|
||||
domSearchPlaceholder.classList.remove("hidden");
|
||||
curSearchIndex = -1;
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
startSearch();
|
||||
}
|
||||
}
|
||||
|
||||
function onSearchKeyDown(ev) {
|
||||
switch (getKeyString(ev)) {
|
||||
case "Enter":
|
||||
@ -3164,13 +3180,8 @@ var zigAnalysis;
|
||||
ev.stopPropagation();
|
||||
return;
|
||||
case "Esc":
|
||||
domSearch.value = "";
|
||||
domSearch.blur();
|
||||
curSearchIndex = -1;
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
startSearch();
|
||||
return;
|
||||
onEscape(ev);
|
||||
return
|
||||
case "Up":
|
||||
moveSearchCursor(-1);
|
||||
ev.preventDefault();
|
||||
@ -3245,18 +3256,17 @@ var zigAnalysis;
|
||||
function onWindowKeyDown(ev) {
|
||||
switch (getKeyString(ev)) {
|
||||
case "Esc":
|
||||
if (!domHelpModal.classList.contains("hidden")) {
|
||||
domHelpModal.classList.add("hidden");
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
}
|
||||
onEscape(ev);
|
||||
break;
|
||||
case "s":
|
||||
domSearch.focus();
|
||||
domSearch.select();
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
startAsyncSearch();
|
||||
if (domHelpModal.classList.contains("hidden")) {
|
||||
// TODO: scroll the page to the very top
|
||||
domSearch.focus();
|
||||
domSearch.select();
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
startAsyncSearch();
|
||||
}
|
||||
break;
|
||||
case "?":
|
||||
ev.preventDefault();
|
||||
@ -3273,6 +3283,7 @@ var zigAnalysis;
|
||||
domHelpModal.style.top =
|
||||
window.innerHeight / 2 - domHelpModal.clientHeight / 2 + "px";
|
||||
domHelpModal.focus();
|
||||
domSearch.blur();
|
||||
}
|
||||
|
||||
function clearAsyncSearch() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user