mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-07-18 00:44:29 -05:00
[PR #1857] [MERGED] fix(staffml): keep command-palette active row in view during keyboard nav #33411
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/harvard-edge/cs249r_book/pull/1857
Author: @farhan523
Created: 6/12/2026
Status: ✅ Merged
Merged: 6/16/2026
Merged by: @profvjreddi
Base:
dev← Head:fix/staffml-cmdk-scroll-active📝 Commits (1)
fafc5b5fix(staffml): keep command-palette active row in view during keyboard nav📊 Changes
3 files changed (+97 additions, -0 deletions)
View changed files
➕
interviews/staffml/src/__tests__/command-palette-scroll.test.tsx(+78 -0)📝
interviews/staffml/src/__tests__/setup.ts(+6 -0)📝
interviews/staffml/src/components/CommandPalette.tsx(+13 -0)📄 Description
Problem (accessibility)
The Cmd+K command-palette result list is scrollable (
max-h-[60vh]). Arrowing past the fold updatedaria-activedescendantand the highlight class, but nothing scrolled the active row back into the viewport — so keyboard-only users lost the highlight off-screen on longer result sets (e.g. a question search returning Pages + Topics + 12 questions).Fix
Scroll the active row into view whenever
activeIdxchanges, usingblock: "nearest"so an already-visible row — e.g. one set active viaonMouseEnterhover — never triggers a scroll jump.Test
Adds
command-palette-scroll.test.tsxcovering ArrowDown/ArrowUp navigation, plus a jsdomscrollIntoViewstub in the shared test setup (jsdom doesn't implement it). Full suite: 113 passing.tsc --noEmitclean.Note
Best reviewed/merged after #1856 — the command palette is currently not mounted in
app/layout.tsx, so this keyboard behavior is only reachable once that mount lands. The two changes touch different files and do not conflict.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.