fix(ui): open help before modal dispatch

This commit is contained in:
Bjarne Øverli
2026-07-20 23:40:46 +02:00
parent 09b738eed6
commit 94e2e6ace7
2 changed files with 34 additions and 4 deletions
+7 -4
View File
@@ -182,6 +182,13 @@ func (m *Model) handleKey(msg tea.KeyPressMsg) tea.Cmd {
if msg.String() == "ctrl+c" {
return m.quit()
}
if msg.String() == "ctrl+k" && !m.keymap.visible {
if m.fullVis {
m.exitFullVisualizer()
}
m.openKeymap()
return nil
}
if m.width > 0 && m.layout.tooSmall() {
if msg.String() == "q" {
return m.quit()
@@ -194,10 +201,6 @@ func (m *Model) handleKey(msg tea.KeyPressMsg) tea.Cmd {
if m.keymap.visible {
return m.handleKeymapKey(msg)
}
if msg.String() == "ctrl+k" {
m.openKeymap()
return nil
}
// Audio device picker overlay
if m.devicePicker.visible {
+27
View File
@@ -0,0 +1,27 @@
package model
import (
"testing"
tea "charm.land/bubbletea/v2"
)
func TestGlobalHelpOpensOverActiveTextInput(t *testing.T) {
m := Model{search: searchState{active: true, query: "jazz"}}
m.handleKey(tea.KeyPressMsg{Code: 'k', Mod: tea.ModCtrl})
if !m.keymap.visible {
t.Fatal("keymap.visible = false after Ctrl+K, want true")
}
if !m.search.active || m.search.query != "jazz" {
t.Fatalf("search state = %+v, want active input preserved", m.search)
}
m.handleKey(tea.KeyPressMsg{Code: 'k', Mod: tea.ModCtrl})
if m.keymap.visible {
t.Fatal("keymap.visible = true after second Ctrl+K, want false")
}
if !m.search.active || m.search.query != "jazz" {
t.Fatalf("search state = %+v after closing help, want active input preserved", m.search)
}
}