diff --git a/components/NotificationList.test.mjs b/components/NotificationList.test.mjs index 7c5050bcd..bdb04cfb2 100644 --- a/components/NotificationList.test.mjs +++ b/components/NotificationList.test.mjs @@ -140,6 +140,20 @@ test("a row shows the event in the viewer's language, and its session name as th assert.match(row.textContent, /Ship it\?/); }); +test("pressing Space on a row opens its session, like Enter", () => { + const opened = []; + const onOpen = (event) => opened.push(event.detail); + window.addEventListener(OPEN_SESSION_EVENT, onOpen); + try { + const { row } = mount(); + act(() => { row().dispatchEvent(new window.KeyboardEvent("keydown", { key: " ", bubbles: true, cancelable: true })); }); + assert.deepEqual(opened, ["n1-session"]); + assert.equal(notificationHistory.get()[0].read, true); + } finally { + window.removeEventListener(OPEN_SESSION_EVENT, onOpen); + } +}); + test("an entry whose session no longer exists still renders and opens by id", () => { act(() => { notificationHistory.add({ type: "error", sessionId: "gone-session", sessionName: null }); }); const row = render(React.createElement(NotificationList)).container.querySelector("li"); diff --git a/components/NotificationList.tsx b/components/NotificationList.tsx index 82881b496..e18f9aaee 100644 --- a/components/NotificationList.tsx +++ b/components/NotificationList.tsx @@ -102,9 +102,13 @@ function NotificationRow({ entry }: { entry: NotificationHistoryEntry }) { data-swipe-dismiss // With an action the row is the only way to run it (there is no Open link), so keyboard users can focus it. tabIndex={open ? 0 : undefined} + role={open ? "button" : undefined} className={open ? "ui-focus-ring" : undefined} onKeyDown={open ? (event) => { - if (event.key !== "Enter" || event.target !== event.currentTarget) return; + // Space, like Enter, activates the row: without it a keyboard user + // on a focused row just scrolls the page instead of opening the + // session, and the row was not announced as actionable either. + if ((event.key !== "Enter" && event.key !== " ") || event.target !== event.currentTarget) return; event.preventDefault(); open(); } : undefined} diff --git a/components/ThemeSwitcher.tsx b/components/ThemeSwitcher.tsx index e0409d592..95b4be5df 100644 --- a/components/ThemeSwitcher.tsx +++ b/components/ThemeSwitcher.tsx @@ -209,8 +209,11 @@ export function ThemeSwitcher() { flexDirection: isMobile ? "column" : undefined, gridTemplateColumns: isMobile ? undefined : "1fr 1fr", gap: isMobile ? 4 : 8, - maxHeight: isMobile ? 380 : undefined, - overflowY: isMobile ? "auto" : undefined, + // Desktop previously had no cap, so on short viewports the + // fixed-position menu clipped its bottom themes with no way + // to scroll to them. Cap against the viewport, as on mobile. + maxHeight: isMobile ? 380 : "calc(100vh - 56px)", + overflowY: "auto", }} > {/* Light column */}