mirror of
https://github.com/anomalyco/opentui.git
synced 2026-04-25 13:06:00 +03:00
[GH-ISSUE #576] feat: Auto-focus on click (browser-like behavior) #154
Labels
No labels
bug
core
documentation
feature
good first issue
help wanted
pull-request
question
react
solid
tmux
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/opentui#154
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @eitanalka on GitHub (Jan 23, 2026).
Original GitHub issue: https://github.com/anomalyco/opentui/issues/576
Problem
Currently, clicking on a focusable element (input, scrollbox, etc.) doesn't automatically focus it. Users must manually handle
onMouseDownto set focus state, which is different from browser behavior.Proposed Solution
Add browser-like auto-focus behavior to the renderer:
focus()on the clicked elementisWithinContainerBenefits
onMouseDownhandlers needed)focusedBorderColor/focusedBackgroundColorstyle propsImplementation
I have a working implementation with tests ready:
Code changes:
packages/core/src/renderer.ts- ~10 lines to handle auto-focus with parent bubblingpackages/core/src/tests/renderer.focus.test.ts- 3 tests covering the behaviorHappy to open a PR if this approach looks good!
@kommander commented on GitHub (Jan 24, 2026):
makes sense and looks simple enough
@eitanalka commented on GitHub (Jan 25, 2026):
Thank you. I opened a PR.
@viralcodex commented on GitHub (Jan 28, 2026):
hi @eitanalka, in your PR please add fixes: to link it to this issue automatically