-
Notifications
You must be signed in to change notification settings - Fork 226
Open
Description
Description
In
Lines 256 to 274 in a01a1e3
| g.selector.Range(func(i int, field Field) bool { | |
| switch msg := msg.(type) { | |
| case tea.KeyMsg: | |
| break | |
| default: | |
| m, cmd := field.Update(msg) | |
| g.selector.Set(i, m.(Field)) | |
| cmds = append(cmds, cmd) | |
| } | |
| if g.selector.Index() == i { | |
| m, cmd := field.Update(msg) | |
| g.selector.Set(i, m.(Field)) | |
| cmds = append(cmds, cmd) | |
| } | |
| m, cmd := field.Update(updateFieldMsg{}) | |
| g.selector.Set(i, m.(Field)) | |
| cmds = append(cmds, cmd) | |
| return true | |
| }) |
msg is not a tea.KeyMsg and if g.selector.Index() == i is true, then field.Update(msg) will be called twice for the same field and msg.
At the very least, this requires custom Field implementations to look out for duplicate custom message types being received.
For what it's worth, I was able to get the behavior I expected by changing the linked block to
g.selector.Range(func(i int, field Field) bool {
var forwardMsg bool = true
// Don't forward key messages to non-selected fields.
if _, ok := msg.(tea.KeyMsg); ok && g.selector.Index() != i {
forwardMsg = false
}
if forwardMsg {
m, cmd := field.Update(msg)
g.selector.Set(i, m.(Field))
cmds = append(cmds, cmd)
}
m, cmd := field.Update(updateFieldMsg{})
g.selector.Set(i, m.(Field))
cmds = append(cmds, cmd)
return true
})Version
Environment
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels