Skip to content

Make the TUI Tab ring follow the Responsive variant actually drawn - #34

Merged
archlemon merged 1 commit into
mainfrom
fix/tui-responsive-focus
Nov 28, 2026
Merged

archlemon merged 1 commit into
mainfrom
fix/tui-responsive-focus

Conversation

@archlemon

Copy link
Copy Markdown
Member

Summary

Fixes #33. The renderer picks a Responsive variant from the width of its pane, but collectFocusables re-decided it from the terminal width. Inside a Sidebar or Split pane they disagree: at 100 columns a 24-cell sidebar draws [ Small ], but Tab focused btn:Big, a control that wasn't drawn, and the drawn button was unreachable.

  • The renderer records which variant each Responsive element drew, in tree order (tuiRenderer.picks). It restores them like the button keys when a collapsed Row re-renders its children.
  • collectFocusables follows those picks, and uses the terminal width only for Responsive elements the last frame did not cover.
  • View() rebuilds the ring after rendering, so it always matches the frame on screen. Key and mouse handling between frames use the last frame's picks.
  • New ResponsiveEl.pickIndex / variant helpers; pick is built on them.

Test plan

  • TestTabRingFollowsTheVariantThePaneDraws: Tab focuses and Enter activates the drawn Small button. With the ring fed no picks, it fails with "Tab focused btn:Big".
  • go test -race ./..., make e2e, both vets

The renderer picks a Responsive variant from its pane's width, but the
focus ring re-decided it from the terminal width, so inside a Sidebar
or Split pane Tab could land on a control that was not drawn while the
drawn one was unreachable. The renderer now records each Responsive
element's pick in tree order, and the focus ring follows those picks,
falling back to the terminal width only for elements not yet rendered.
The ring is rebuilt after each render.

Closes #33
@archlemon
archlemon merged commit 14a1399 into main Nov 28, 2026
2 checks passed
@archlemon
archlemon deleted the fix/tui-responsive-focus branch November 28, 2026 07:40
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.

TUI Tab ring picks Responsive variants by terminal width, not pane width

1 participant