Small bug fix to table select filtering

This commit is contained in:
Leon Mika 2022-03-28 04:54:37 +00:00 committed by GitHub
parent aa828df3ae
commit 826a28664a
3 changed files with 13 additions and 8 deletions

View file

@ -7,7 +7,7 @@ type tableItem struct {
}
func (ti tableItem) FilterValue() string {
return ""
return ti.name
}
func (ti tableItem) Title() string {

View file

@ -26,7 +26,9 @@ func newListController(tableNames []string, w, h int) listController {
delegate := list.NewDefaultDelegate()
delegate.ShowDescription = false
return listController{list.New(items, delegate, w, h)}
list := list.New(items, delegate, w, h)
return listController{list: list}
}
func (l listController) Init() tea.Cmd {

View file

@ -1,6 +1,7 @@
package tableselect
import (
"github.com/charmbracelet/bubbles/list"
tea "github.com/charmbracelet/bubbletea"
"github.com/lmika/awstools/internal/dynamo-browse/controllers"
"github.com/lmika/awstools/internal/dynamo-browse/ui/teamodels/layout"
@ -38,14 +39,16 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if m.pendingSelection != nil {
switch msg.String() {
case "enter":
var sel controllers.PromptForTableMsg
sel, m.pendingSelection = *m.pendingSelection, nil
if m.listController.list.FilterState() != list.Filtering {
var sel controllers.PromptForTableMsg
sel, m.pendingSelection = *m.pendingSelection, nil
return m, sel.OnSelected(m.listController.list.SelectedItem().(tableItem).name)
default:
m.listController = cc.Collect(m.listController.Update(msg)).(listController)
return m, cc.Cmd()
return m, sel.OnSelected(m.listController.list.SelectedItem().(tableItem).name)
}
}
m.listController = cc.Collect(m.listController.Update(msg)).(listController)
return m, cc.Cmd()
}
}