🐛 Fix TUI focus navigation requiring Tab/arrow twice (#2) #14
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "ossfixx4756/sshception:fix/2-tui-focus-navigation-twice"
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?
Bug
Closes #2
On the TUI home screen, moving focus to the next action could require pressing Tab / arrow-down twice: the first keypress appeared to do nothing, and only the second press visibly moved focus. This was especially visible after interacting with the host-selection dialog.
Root cause
Three focus-management issues in
src/tui/views/home.js, around reblessed's (theblessedfork used here)Formwidget:Formregisters a bubblingelement keypresshandler that maps Escape toform.focus()(seenode_modules/blessed/lib/widgets/form.js). After the host actions dialog was open, Escape moved focus onto its invisible form container, and the next Tab/Down was first consumed moving from that container onto a child action - the first keypress was effectively lost. The same Escape-to-container strand existed on the main actions form._selectedcursor, so after any Tab/arrow traversal, reopening the dialog and pressing Tab once could initially move focus back to the remembered child (often the already-focused Cancel) instead of to Connect - another first keypress that did not advance.emitter.on('escape', ...)and never removed it. The dashboard remounts the whole home view on each navigation cycle using the same session-wide emitter (seesrc/tui/controllers/dashboard.js_home()), so stale closures piled up and could keep stealing Escape.Solution
element keypresslistener (registered after the Form's built-in one, so it runs last) overrides the container self-focus.resetSelected()is called before focusing Cancel when a host row is opened, so the first Tab always lands on Connect.Verification
yarn test-> 6 passing.node --checkon the changed JS files.Scope / notes
yarn testnpm script. CLI/connect/account paths are untouched.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.