Add keyboard navigation - #10
Conversation
|
@jadefw is attempting to deploy a commit to the Dara's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@codex tldr of the pr? |
TL;DRThis PR adds keyboard shortcuts to the gallery’s variant switcher:
It also avoids triggering shortcuts while the user is typing in an input, textarea, or editable element, and ignores shortcuts combined with Ctrl, Cmd, or Alt. The keyboard listener is removed when the component unmounts. src/components/gallery/variant-header.tsxL40-L52 src/components/gallery/variant-header.tsxL78-L80 Checks
No code changes were needed for this summary. |
|
@jadefw fix the merge conflicts n i'll get to merge |
|
@greptile-ai |
Greptile SummaryThe gallery header adds keyboard navigation for home, comparison, and iteration selection. Browser validation confirmed that lowercase Confidence Score: 4/5Not ready to merge because Shift-modified gallery navigation shortcuts fail in the rendered application. A production build and Chromium browser session directly exercised the affected keyboard interactions. The observed URLs confirm that lowercase shortcuts work while Shift-modified equivalents do not. Files Needing Attention: src/components/gallery/variant-header.tsx
What T-Rex did
|
| if (e.key === "h") { | ||
| e.preventDefault(); | ||
| router.push("/"); | ||
| return; | ||
| } | ||
|
|
||
| if (e.key === "c") { |
There was a problem hiding this comment.
Shift-modified letter shortcuts do not navigate
The handler only matches lowercase "h" and "c". On the rendered gallery route, lowercase shortcuts navigate correctly, but Shift+H and Shift+C leave the visitor on the current variant even when focus is outside an editable element. Normalize the letter key before comparing it so navigation works regardless of Shift or Caps Lock state.
Artifacts
Executed Playwright shortcut probe source
- The authored Chromium Playwright probe opens the live gallery variant, sends lowercase and Shift-uppercase H/C keys outside editable controls, and records the resulting URLs; the executable test source establishes the reproduction method and takeaway.
Observed gallery shortcut navigation output
- Output captured from `node trex-artifacts/variant-shortcuts-probe.mjs` in `/home/user/repo` records each key, non-editable BODY focus, expected URL, and actual URL; lowercase navigation works while both Shift-uppercase routes fail, the takeaway.
▶ Lowercase h shortcut navigating from the gallery variant to home
- Chromium recording of the real gallery variant before the Shift-uppercase comparison, showing lowercase `h` navigating to the home URL; the baseline shortcut works, the takeaway.
Poster frame after lowercase h navigation to home
- Poster frame from the lowercase `h` recording after the gallery route navigated to home; it visually supports the working lowercase baseline, the takeaway.
▶ Shift+H shortcut remaining on the gallery variant
- Chromium recording of `Shift+H` on the same live gallery variant, showing the route remains unchanged rather than navigating home; the Shift-uppercase shortcut failure is confirmed, the takeaway.
Poster frame after Shift+H leaves the gallery variant unchanged
- Poster frame from the Shift+H recording showing the same gallery variant still rendered after the key press; uppercase navigation did not occur, the takeaway.
This PR adds keyboard navigation to the VariantSwitcher to make switching between views and variants way smoother:
Shortcuts are disabled when typing in input fields or using modifier keys (Ctrl/Cmd) to prevent accidental triggers.