Fix arrow key scrolling and make it work on keydown instead of up
There is an issue with the new key based nav system. When control elements lose their focus, there is no good way to bring it back.
This commit is contained in:
parent
7e15316ad6
commit
91dc1c1296
@ -6,5 +6,6 @@
|
||||
{"title":"GitHub", "link": "https://github.com/lambdapaul"},
|
||||
{"title":"GitLab", "link": "https://gitlab.com/lambdapaul"},
|
||||
{"title":"Mastodon", "link": "https://mastodon.social/@lambdapaul"},
|
||||
{"title":"Matrix", "link": "https://matrix.to/#/@lambdapaul:matrix.org"},
|
||||
{"title":"Keybase", "link": "https://keybase.io/lambdapaul"}
|
||||
]
|
@ -77,7 +77,7 @@ function fuzzyInit(pagesFileName) {
|
||||
}
|
||||
);
|
||||
|
||||
document.body.addEventListener("keyup", (e) => {
|
||||
document.body.addEventListener("keydown", (e) => {
|
||||
if (e.code === "ArrowDown" || e.code === "ArrowUp") {
|
||||
if (resultBlock.childNodes === null)
|
||||
return;
|
||||
@ -90,6 +90,7 @@ function fuzzyInit(pagesFileName) {
|
||||
let currNode = document.activeElement;
|
||||
|
||||
if (searchField === currNode) {
|
||||
e.preventDefault();
|
||||
if (e.code === "ArrowDown")
|
||||
resultNodes[0].focus();
|
||||
else
|
||||
@ -100,6 +101,7 @@ function fuzzyInit(pagesFileName) {
|
||||
if (Array.from(resultNodes).indexOf(currNode) < 0)
|
||||
return;
|
||||
|
||||
e.preventDefault();
|
||||
if (e.code === "ArrowDown")
|
||||
if (currNode.nextElementSibling === null)
|
||||
searchField.focus();
|
||||
|
Loading…
Reference in New Issue
Block a user