diff --git a/internal/ui/list/list.go b/internal/ui/list/list.go index 33a5087c9ceae3f03bb2c8f78b2cc8089f87057c..c3693494881c0a600f3d519471835789ebd54530 100644 --- a/internal/ui/list/list.go +++ b/internal/ui/list/list.go @@ -79,7 +79,7 @@ func (l *List) Gap() int { func (l *List) AtBottom() bool { const margin = 2 - if len(l.items) == 0 { + if len(l.items) == 0 || l.offsetIdx >= len(l.items)-1 { return true } diff --git a/internal/ui/model/chat.go b/internal/ui/model/chat.go index 723e97fb76c04d75922a5aec60d9afa970e41d97..8deb2c3992e249b7baa78ca693f88beaf44ae5d4 100644 --- a/internal/ui/model/chat.go +++ b/internal/ui/model/chat.go @@ -439,6 +439,9 @@ func (m *Chat) ToggleExpandedSelectedItem() { if expandable, ok := m.list.SelectedItem().(chat.Expandable); ok { expandable.ToggleExpanded() m.list.ScrollToIndex(m.list.Selected()) + if m.list.AtBottom() { + m.list.ScrollToBottom() + } } } @@ -547,6 +550,9 @@ func (m *Chat) HandleDelayedClick(msg DelayedClickMsg) bool { expandable.ToggleExpanded() } m.list.ScrollToIndex(m.list.Selected()) + if m.list.AtBottom() { + m.list.ScrollToBottom() + } return handled }