Reliably refocus the terminal after a channel switch (#35) #41
No reviewers
Labels
No labels
bug
docs
enhancement
good first issue
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
pedromcaraujo/forge!41
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/terminal-focus"
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?
Follow-up to #35 / #36 — the earlier fix (
focusGen+ a wider retry window)still left focus off the shell for one class of device, because two independent
causes were in play:
focusTerm()bailed onIS_TOUCH.IS_TOUCHis a device capability(
maxTouchPoints > 0/pointer: coarse), so it's true for touchscreenlaptops, 2-in-1s and Chromebooks driven with a keyboard — and on those the
focus code never ran at all. Now gated on a live input-modality flag
(
lastInputWasTouch): only a genuine finger tap suppresses auto-focus (whichis what pops the Android soft keyboard); any keyboard/mouse/stylus input
focuses the shell, even on touch-capable hardware.
suppressTermKeyboardisgated on the same flag, keeping the two paths mutually exclusive.
The "focus stuck" check could pass falsely. It read only
frame.contentDocument.activeElement === ta, which can be true inside theiframe while keystrokes still land on the top document. Now requires both
the top document to hold the iframe and the iframe to hold its textarea
before it stops retrying.
Retained from #36: the
focusGencounter that supersedes the earlier in-flightattempt from
closePalette. The wide fixed-schedule retry is replaced by aself-scheduling poll (~3 s, guarded by
focusGen) that also bails if the userhas meanwhile focused another launcher control.
Verify: on a desktop/keyboard device, switch channels from the palette
(Alt+K) and via the sidebar; the shell should take focus without a click. On a
phone, the soft keyboard should still stay down on switch.