fix(ui): open help before modal dispatch
This commit is contained in:
+7
-4
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user