Repository navigation
Fix TUI focus ring and key routing - #30
Merged
Merged
Conversation
- Focus is held by ID: when the focused control leaves the view focus clears instead of sliding onto whatever shifted into its slot. - Disabled inputs and text areas, and checkboxes without an ID, stay out of the Tab ring; a control without an ID never renders as focused. - Key routing edits the input or text area the focus ring found, which is the visible Responsive variant, instead of looking the ID up again across every variant. formValues reads the visible variant too. - Buttons sharing a label get unique focus keys (#2, #3), so Enter on the second runs its own OnClick. - Clicking a Select cycles it instead of submitting its form. - A keystroke builds the View twice instead of five times. Closes #26
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
Fixes #26, from the TUI audit.
tuiFocusManagertracked a cursor index. When the focused button left the view, focus silently moved to the control that shifted into its slot, and Enter activated it. Focus now stays on the same control wherever it moves, and clears if that control leaves.InputandTextAreano longer join the Tab ring (they used to accept typing).""no longer renders as focused (and gets a live cursor) while nothing has focus.focusablenow carries the input or text-area element, so key routing edits the control the ring found: the visible Responsive variant. PreviouslyfindInputByIDsearched every variant and Enter dispatched a hidden variant'sOnSubmit.formValuesreads the visible variant too. The now-unusedfindInputByID/findAreaByIDare removed.btn:Delete,btn:Delete#2), numbered identically by the ring and the renderer. Enter on the second button now runs its ownOnClick.Test plan
focus_ring_test.go, one test per item above. Six of the seven fail on main (for example "focus slid onto btn:c", "Enter dispatched narrow at width 80", "built the view 5 times"). The Select-click test can't build against main because it uses the new fields.go test -race ./...,go vet ./...,GOOS=js GOARCH=wasm go vet .