From 96a9afb695c5de58d1d1535a21c3a5341fecebda Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Mon, 3 Jan 2022 13:26:19 -0800 Subject: [PATCH 1/2] fix(list): check items slice len Signed-off-by: Christian Stewart --- list/list.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/list/list.go b/list/list.go index 181c707a..e38e38ec 100644 --- a/list/list.go +++ b/list/list.go @@ -606,7 +606,7 @@ func (m *Model) updateKeybindings() { m.KeyMap.CloseFullHelp.SetEnabled(false) default: - hasItems := m.items != nil + hasItems := len(m.items) != 0 m.KeyMap.CursorUp.SetEnabled(hasItems) m.KeyMap.CursorDown.SetEnabled(hasItems) From f668980dbbf8dd3465d3ebf600a3f574d5aafe2a Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Mon, 3 Jan 2022 14:00:59 -0800 Subject: [PATCH 2/2] fix(list): update keybindings when setting items Bug: when calling SetItems when items was previously empty, the keybindings for up/down do not appear. Fix: call updateKeybindings in SetItems. Signed-off-by: Christian Stewart --- list/list.go | 1 + 1 file changed, 1 insertion(+) diff --git a/list/list.go b/list/list.go index e38e38ec..c5f98b26 100644 --- a/list/list.go +++ b/list/list.go @@ -292,6 +292,7 @@ func (m *Model) SetItems(i []Item) tea.Cmd { } m.updatePagination() + m.updateKeybindings() return cmd }