fix(ui/chat): add fallbacks for cycle between widgets (#731)

This commit is contained in:
xqrs 2026-02-01 22:35:07 +03:00 • committed by GitHub
parent da50e3a8a2
commit 25c062e2d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -155,12 +155,16 @@ func (v *View) focusMessageInput() bool {
func (v *View) focusPrevious() {
switch v.app.GetFocus() {
case v.guildsTree:
v.focusMessageInput()
case v.messagesList: // Handle both a.messagesList and a.flex as well as other edge cases (if there is).
if ok := v.focusGuildsTree(); !ok {
v.app.SetFocus(v.messageInput)
if v.focusGuildsTree() {
return
}
fallthrough
case v.guildsTree:
if v.focusMessageInput() {
return
}
fallthrough
case v.messageInput:
v.app.SetFocus(v.messagesList)
}
@ -168,14 +172,18 @@ func (v *View) focusPrevious() {
func (v *View) focusNext() {
switch v.app.GetFocus() {
case v.messagesList:
if v.focusMessageInput() {
return
}
fallthrough
case v.messageInput: // Handle both a.messageInput and a.flex as well as other edge cases (if there is).
if v.focusGuildsTree() {
return
}
fallthrough
case v.guildsTree:
v.app.SetFocus(v.messagesList)
case v.messagesList:
v.focusMessageInput()
case v.messageInput: // Handle both a.messageInput and a.flex as well as other edge cases (if there is).
if ok := v.focusGuildsTree(); !ok {
v.app.SetFocus(v.messagesList)
}
}
}