Skip to content

Commit

Permalink
fix(list): fix list display area overflow.
Browse files Browse the repository at this point in the history
The number of Items per a page depend on  pagination height.
However, pagination height may changes if it enabled or disabled.
Re-runing updatePagination() resolves this if needed.
  • Loading branch information
tbistr committed Aug 11, 2023
1 parent 95d7be5 commit 06b9653
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ func (m *Model) updateKeybindings() {
func (m *Model) updatePagination() {
index := m.Index()
availHeight := m.height
paginationHeight := 0

if m.showTitle || (m.showFilter && m.filteringEnabled) {
availHeight -= lipgloss.Height(m.titleView())
Expand All @@ -736,7 +737,8 @@ func (m *Model) updatePagination() {
availHeight -= lipgloss.Height(m.statusView())
}
if m.showPagination {
availHeight -= lipgloss.Height(m.paginationView())
paginationHeight = lipgloss.Height(m.paginationView())
availHeight -= paginationHeight
}
if m.showHelp {
availHeight -= lipgloss.Height(m.helpView())
Expand All @@ -758,6 +760,12 @@ func (m *Model) updatePagination() {
if m.Paginator.Page >= m.Paginator.TotalPages-1 {
m.Paginator.Page = max(0, m.Paginator.TotalPages-1)
}

// Items per page depends on old pagination height.
// However, pagination height also depends on items per page.
if m.showPagination && paginationHeight != lipgloss.Height(m.paginationView()) {
m.updatePagination()
}
}

func (m *Model) hideStatusMessage() {
Expand Down

0 comments on commit 06b9653

Please sign in to comment.