diff --git a/internal/ui/model/chat.go b/internal/ui/model/chat.go index 8deb2c3992e249b7baa78ca693f88beaf44ae5d4..00a17ecfc5042dd42f4d24682b135667d1345386 100644 --- a/internal/ui/model/chat.go +++ b/internal/ui/model/chat.go @@ -437,8 +437,9 @@ func (m *Chat) MessageItem(id string) chat.MessageItem { // ToggleExpandedSelectedItem expands the selected message item if it is expandable. func (m *Chat) ToggleExpandedSelectedItem() { if expandable, ok := m.list.SelectedItem().(chat.Expandable); ok { - expandable.ToggleExpanded() - m.list.ScrollToIndex(m.list.Selected()) + if !expandable.ToggleExpanded() { + m.list.ScrollToIndex(m.list.Selected()) + } if m.list.AtBottom() { m.list.ScrollToBottom() } @@ -547,9 +548,10 @@ func (m *Chat) HandleDelayedClick(msg DelayedClickMsg) bool { handled := clickable.HandleMouseClick(ansi.MouseButton1, msg.X, msg.Y) // Toggle expansion if applicable. if expandable, ok := selectedItem.(chat.Expandable); ok { - expandable.ToggleExpanded() + if !expandable.ToggleExpanded() { + m.list.ScrollToIndex(m.list.Selected()) + } } - m.list.ScrollToIndex(m.list.Selected()) if m.list.AtBottom() { m.list.ScrollToBottom() }