Skip to content

feat(frontend): add j/k keybinds to move between search results#1231

Open
KiaraGrouwstra wants to merge 1 commit intomainfrom
feat-jk-result-navigation
Open

feat(frontend): add j/k keybinds to move between search results#1231
KiaraGrouwstra wants to merge 1 commit intomainfrom
feat-jk-result-navigation

Conversation

@KiaraGrouwstra
Copy link
Copy Markdown
Collaborator

Adds vim-style navigation (matching the keybinds used by GitHub and DuckDuckGo) for moving between result items on the package, options and flake search pages. Pressing j selects the next result, k the previous, and Enter activates the selected result the same way a mouse click on its title would (toggling its expanded view).

Selection is tracked via a result-selected class rather than browser focus, since the result <li>s are not focusable by default and the global *:focus { outline-width: 0 } rule would hide any focus ring. The class reuses the existing outline-visible mixin so the active result gets the same blue outline used for :focus-visible.

The handler ignores key events from inputs and any modifier combinations, so existing shortcuts (e.g. Ctrl+K, /) and normal typing in the search box are unaffected.

Closes #1086.

Disclaimer: i used a coding agent in the creation of this patch.

@KiaraGrouwstra KiaraGrouwstra requested a review from raboof April 25, 2026 15:45
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 25, 2026

@github-actions github-actions Bot temporarily deployed to pull request April 25, 2026 15:46 Inactive
Adds vim-style navigation (matching the keybinds used by GitHub and
DuckDuckGo) for moving between result items on the package, options and
flake search pages. Pressing `j` selects the next result, `k` the
previous, and `Enter` activates the selected result the same way a
mouse click on its title would (toggling its expanded view).

Selection is tracked via a `result-selected` class rather than browser
focus, since the result `<li>`s are not focusable by default and the
global `*:focus { outline-width: 0 }` rule would hide any focus ring.
The class reuses the existing `outline-visible` mixin so the active
result gets the same blue outline used for `:focus-visible`.

The handler ignores key events from inputs and any modifier
combinations, so existing shortcuts (e.g. `Ctrl+K`, `/`) and normal
typing in the search box are unaffected.

Closes #1086
@KiaraGrouwstra KiaraGrouwstra force-pushed the feat-jk-result-navigation branch from 4524be2 to 8ad1554 Compare April 25, 2026 16:35
@github-actions github-actions Bot temporarily deployed to pull request April 25, 2026 16:36 Inactive
Comment thread frontend/src/index.js
Comment on lines +70 to +73
// Elm's VDOM diff replaces the `class` attribute on re-render (e.g. when
// toggling a result's expanded view), which would otherwise wipe our
// `result-selected` class. Re-apply it whenever the DOM changes.
new MutationObserver(applySelection).observe(document.body, {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this suggest it make more sense to implement this functionality in Elm instead of in js?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case that seems worse tbh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: J/K keybinds to move focus between results

2 participants