on main help sign in
fix(ui): ensure we anchor the chat view to the bottom when toggling (#2117)
3bda767Ayman Bagabas
internal/ui/list/list.go+1−1
@@ -79,7 +79,7 @@ func (l *List) Gap() int {
79func (l *List) AtBottom() bool {
79func (l *List) AtBottom() bool {
80 const margin = 2
80 const margin = 2
81
81
82− if len(l.items) == 0 {
82+ if len(l.items) == 0 || l.offsetIdx >= len(l.items)-1 {
83 return true
83 return true
84 }
84 }
85
85
internal/ui/model/chat.go+6
@@ -439,6 +439,9 @@ func (m *Chat) ToggleExpandedSelectedItem() {
439 if expandable, ok := m.list.SelectedItem().(chat.Expandable); ok {
439 if expandable, ok := m.list.SelectedItem().(chat.Expandable); ok {
440 expandable.ToggleExpanded()
440 expandable.ToggleExpanded()
441 m.list.ScrollToIndex(m.list.Selected())
441 m.list.ScrollToIndex(m.list.Selected())
442+ if m.list.AtBottom() {
443+ m.list.ScrollToBottom()
444+ }
442 }
445 }
443}
446}
444
447
@@ -547,6 +550,9 @@ func (m *Chat) HandleDelayedClick(msg DelayedClickMsg) bool {
547 expandable.ToggleExpanded()
550 expandable.ToggleExpanded()
548 }
551 }
549 m.list.ScrollToIndex(m.list.Selected())
552 m.list.ScrollToIndex(m.list.Selected())
553+ if m.list.AtBottom() {
554+ m.list.ScrollToBottom()
555+ }
550 return handled
556 return handled
551 }
557 }
552
558