From 742bf1dc37cafec74e59b059b0a941667908e857 Mon Sep 17 00:00:00 2001 From: Kujtim Hoxha Date: Fri, 25 Jul 2025 11:41:30 +0200 Subject: [PATCH] chore: fix selected item --- internal/tui/exp/list/list.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/tui/exp/list/list.go b/internal/tui/exp/list/list.go index 68ed2de3a6a14b9d68c7f8d45644f27df86ecdec..1970abb3ea925715fe01d74358d0e89c1a637fb7 100644 --- a/internal/tui/exp/list/list.go +++ b/internal/tui/exp/list/list.go @@ -746,17 +746,21 @@ func (l *list[T]) GetSize() (int, int) { // GoToBottom implements List. func (l *list[T]) GoToBottom() tea.Cmd { + if l.offset != 0 { + l.selectedItem = "" + } l.offset = 0 l.direction = DirectionBackward - l.selectedItem = "" return l.render() } // GoToTop implements List. func (l *list[T]) GoToTop() tea.Cmd { + if l.offset != 0 { + l.selectedItem = "" + } l.offset = 0 l.direction = DirectionForward - l.selectedItem = "" return l.render() } @@ -997,6 +1001,7 @@ func (l *list[T]) UpdateItem(id string, item T) tea.Cmd { if cmd != nil { cmds = append(cmds, cmd) } + // if the item is at least partially below the viewport } else if oldPosition < oldItem.end { newItem, ok := l.renderedItems.Get(item.ID())