Переглянути джерело

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

xqrs 2 місяців тому
батько
коміт
25c062e2d7
1 змінених файлів з 17 додано та 9 видалено
  1. 17 9
      internal/ui/chat/view.go

+ 17 - 9
internal/ui/chat/view.go

@@ -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.guildsTree:
-		v.app.SetFocus(v.messagesList)
 	case v.messagesList:
-		v.focusMessageInput()
+		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 ok := v.focusGuildsTree(); !ok {
-			v.app.SetFocus(v.messagesList)
+		if v.focusGuildsTree() {
+			return
 		}
+		fallthrough
+	case v.guildsTree:
+		v.app.SetFocus(v.messagesList)
 	}
 }