Arrow keys on the Config view's server dropdowns
The form navigation recognised dropdowns only as *tview.DropDown, so on the new profile and folder dropdowns ←→ did nothing and ↑↓ left an open list instead of moving through it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019reK4DUGYqDUjniWYJvwUW
This commit is contained in:
@@ -411,3 +411,40 @@ func TestDefaultsAreChosenFromTheServer(t *testing.T) {
|
||||
t.Errorf("offline: %d options, result %q", p.GetOptionCount(), v.status.GetText(false))
|
||||
}
|
||||
}
|
||||
|
||||
func TestServerChoiceWorksWithTheArrowKeys(t *testing.T) {
|
||||
a := newTestApp(t)
|
||||
v := a.settings
|
||||
p := v.choices["radarr.profile"]
|
||||
v.choiceGen["radarr"] = 1
|
||||
v.applyChoices("radarr", 1, []string{"Any", "HD-1080p"}, nil, nil)
|
||||
v.focusGroup(0, false)
|
||||
keys := v.form.GetInputCapture()
|
||||
send := func(k tcell.Key) { keys(tcell.NewEventKey(k, 0, 0)) }
|
||||
send(tcell.KeyDown) // API key
|
||||
send(tcell.KeyDown) // Default quality profile
|
||||
if item, _ := v.form.GetFocusedItemIndex(); v.form.GetFormItem(item) != p {
|
||||
t.Fatalf("on %q", v.form.GetFormItem(item).GetLabel())
|
||||
}
|
||||
|
||||
// → and ← change the value, like on every other dropdown.
|
||||
send(tcell.KeyRight)
|
||||
send(tcell.KeyRight)
|
||||
if p.value != "HD-1080p" || !v.dirty {
|
||||
t.Errorf("→→: value %q, dirty %v", p.value, v.dirty)
|
||||
}
|
||||
send(tcell.KeyLeft)
|
||||
if p.value != "Any" {
|
||||
t.Errorf("←: value %q", p.value)
|
||||
}
|
||||
// While its list is open, ↑↓ belong to the list, not to the form.
|
||||
var focus func(tview.Primitive)
|
||||
focus = func(q tview.Primitive) { q.Focus(focus) }
|
||||
p.InputHandler()(tcell.NewEventKey(tcell.KeyEnter, 0, 0), focus)
|
||||
if !p.IsOpen() {
|
||||
t.Fatal("Enter does not open the list")
|
||||
}
|
||||
if got := keys(tcell.NewEventKey(tcell.KeyDown, 0, 0)); got == nil {
|
||||
t.Error("↓ in the open list was taken by the form")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user