From 1a1c56200ca54a73b837ba7336c5193470c159a4 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Mon, 28 Aug 2023 22:01:50 -0400 Subject: [PATCH] m and escape to open close menu. and set focus on actions after scroll. --- docs/honk.1 | 4 ++++ views/honkpage.js | 21 +++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/docs/honk.1 b/docs/honk.1 index a98fa07..bd8a583 100644 --- a/docs/honk.1 +++ b/docs/honk.1 @@ -145,6 +145,10 @@ Scroll to previous honk. Refresh. .It s Scroll down to oldest newest. +.It m +Open menu. +.It esc +Close menu. .It / Search. .El diff --git a/views/honkpage.js b/views/honkpage.js index c3e3e63..99ce903 100644 --- a/views/honkpage.js +++ b/views/honkpage.js @@ -423,8 +423,10 @@ function scrollnexthonk() { var h = honks[i]; var b = h.getBoundingClientRect(); if (b.top > 1.0) { - h.scrollIntoView(); - break; + h.scrollIntoView() + 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++) { var b = honks[i].getBoundingClientRect(); if (b.top > -1.0) { - honks[i-1].scrollIntoView(); - break; + honks[i-1].scrollIntoView() + var a = honks[i-1].querySelector(".actions summary") + if (a) a.focus({ preventScroll: true }) + break } } } @@ -459,6 +463,15 @@ function hotkey(e) { case "KeyK": scrollprevioushonk(); 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": document.getElementById("topmenu").open = true document.getElementById("searchbox").focus()