m and escape to open close menu. and set focus on actions after scroll.

This commit is contained in:
Ted Unangst 2023-08-28 22:01:50 -04:00
parent 76da4515bc
commit 1a1c56200c
2 changed files with 21 additions and 4 deletions

View File

@ -145,6 +145,10 @@ Scroll to previous honk.
Refresh. Refresh.
.It s .It s
Scroll down to oldest newest. Scroll down to oldest newest.
.It m
Open menu.
.It esc
Close menu.
.It / .It /
Search. Search.
.El .El

View File

@ -423,8 +423,10 @@ function scrollnexthonk() {
var h = honks[i]; var h = honks[i];
var b = h.getBoundingClientRect(); var b = h.getBoundingClientRect();
if (b.top > 1.0) { if (b.top > 1.0) {
h.scrollIntoView(); h.scrollIntoView()
break; var a = h.querySelector(".actions summary")
if (a) a.focus({ preventScroll: true })
break
} }
} }
} }
@ -434,8 +436,10 @@ function scrollprevioushonk() {
for (var i = 1; i < honks.length; i++) { for (var i = 1; i < honks.length; i++) {
var b = honks[i].getBoundingClientRect(); var b = honks[i].getBoundingClientRect();
if (b.top > -1.0) { if (b.top > -1.0) {
honks[i-1].scrollIntoView(); honks[i-1].scrollIntoView()
break; var a = honks[i-1].querySelector(".actions summary")
if (a) a.focus({ preventScroll: true })
break
} }
} }
} }
@ -459,6 +463,15 @@ function hotkey(e) {
case "KeyK": case "KeyK":
scrollprevioushonk(); scrollprevioushonk();
break; break;
case "KeyM":
var menu = document.getElementById("topmenu")
menu.open = true
menu.querySelector("a").focus()
break
case "Escape":
var menu = document.getElementById("topmenu")
menu.open = false
break
case "Slash": case "Slash":
document.getElementById("topmenu").open = true document.getElementById("topmenu").open = true
document.getElementById("searchbox").focus() document.getElementById("searchbox").focus()