From abfb92d59ba12763f298f42d3fbbc8c987096e51 Mon Sep 17 00:00:00 2001 From: kahme247 <61059522+kahme247@users.noreply.github.com> Date: Mon, 26 Oct 2026 11:36:18 +0000 Subject: [PATCH] fix(ui): notification rows answer Space; cap desktop theme menu to viewport Notification rows were focusable and clickable but their key handler answered only Enter, so a keyboard user pressing Space on a focused row scrolled the page instead of opening the session, and the row carried no role announcing it as actionable. Space now activates the row (preventing the scroll) and focusable rows carry role=button. Separately, the desktop theme menu set a scroll cap only on mobile, so on short viewports its fixed-position grid clipped the bottom themes with no way to reach them by mouse or keyboard. Desktop now caps at calc(100vh - 56px) with overflow auto. --- components/NotificationList.test.mjs | 14 ++++++++++++++ components/NotificationList.tsx | 6 +++++- components/ThemeSwitcher.tsx | 7 +++++-- 3 files changed, 24 insertions(+), 3 deletions(-) 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 */}