Replace menu shortcuts with spatial arrow-key navigation#114
Draft
Replace menu shortcuts with spatial arrow-key navigation#114
Conversation
Replaces installMenuShortcuts with a single auto-installed handler that ray-casts from the focused element's edge in the arrow direction using document.elementFromPoint(). The DOM layout is the navigation graph, so one ~50-line handler covers every kinu widget (dropdowns, tabs, menubar, tree, carousel, dialog buttons, etc.) without per-component wiring. An adjacent open dialog[k] with a [k][selected] child flips on pseudo-focus — the virtual cursor moves [selected] instead of real focus — which is how Combobox keeps the caret in the input while arrows walk options. Handler self-scopes to kinu widgets and skips elements where arrows have native meaning (text inputs, select, slider, radio, etc).
✅ Deploy Preview for kinu-sh ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
Size Change: +1.27 kB (+4.01%) Total Size: 32.8 kB 📦 View Changed
ℹ️ View Unchanged
|
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.
Summary
Replaced the simple up/down arrow navigation system with a more sophisticated spatial navigation implementation that uses ray-casting to find focusable elements in any direction (up, down, left, right).
Key Changes
handleMenuShortcutsKeydown()withhandleArrowKey()that implements spatial navigation viaelementFromPoint()ray-castinginstallMenuShortcuts()function and its guard flag; arrow key handler now installs automatically on module loadinstallMenuShortcuts()calls from ComboboxBase and DropdownMenu components since initialization is now automaticImplementation Details
[selected]attribute)disabledattribute and respects viewport boundariesscrollIntoView()for pseudo-focused elements to ensure visibilityhttps://claude.ai/code/session_01TpntAcHRsAf2hJr2WzyFVD