feat(frontend): add j/k keybinds to move between search results#1231
Open
KiaraGrouwstra wants to merge 1 commit intomainfrom
Open
feat(frontend): add j/k keybinds to move between search results#1231KiaraGrouwstra wants to merge 1 commit intomainfrom
j/k keybinds to move between search results#1231KiaraGrouwstra wants to merge 1 commit intomainfrom
Conversation
Contributor
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
4524be2 to
8ad1554
Compare
raboof
reviewed
Apr 26, 2026
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, { |
Member
There was a problem hiding this comment.
Does this suggest it make more sense to implement this functionality in Elm instead of in js?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
jselects the next result,kthe previous, andEnteractivates the selected result the same way a mouse click on its title would (toggling its expanded view).Selection is tracked via a
result-selectedclass 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 existingoutline-visiblemixin 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.