Skip to content

Commit

Permalink
fix: reset sidebar viewport when row is changed
Browse files Browse the repository at this point in the history
Signed-off-by: Dolev Hadar <dolevc2@gmail.com>
  • Loading branch information
dlvhdr committed Oct 9, 2022
1 parent b58ceaf commit 8294f27
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ui/components/sidebar/sidebar.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ func (m *Model) GetSidebarContentWidth() int {
return m.ctx.Config.Defaults.Preview.Width - 2*contentPadding - borderWidth
}

func (m *Model) ScrollToTop() {
m.viewport.GotoTop()
}

func (m *Model) ScrollToBottom() {
m.viewport.GotoBottom()
}
Expand Down
2 changes: 2 additions & 0 deletions ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ func (m *Model) setCurrSectionId(newSectionId int) {

func (m *Model) onViewedRowChanged() {
m.syncSidebar()
m.sidebar.ScrollToTop()

}

func (m *Model) onWindowSizeChanged(msg tea.WindowSizeMsg) {
Expand Down

0 comments on commit 8294f27

Please sign in to comment.