Skip to content

Commit

Permalink
fix: account for headers in height WithHeight, SetHeight
Browse files Browse the repository at this point in the history
  • Loading branch information
maaslalani committed Nov 27, 2023
1 parent d21a343 commit c0461cd
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func WithRows(rows []Row) Option {
// WithHeight sets the height of the table.
func WithHeight(h int) Option {
return func(m *Model) {
m.viewport.Height = h
m.viewport.Height = h - lipgloss.Height(m.headersView())
}
}

Expand Down Expand Up @@ -296,8 +296,7 @@ func (m *Model) SetWidth(w int) {

// SetHeight sets the height of the viewport of the table.
func (m *Model) SetHeight(h int) {
headerHeight := lipgloss.Height(m.headersView()) // Since headers are truncated, it is always 1
m.viewport.Height = h - headerHeight
m.viewport.Height = h - lipgloss.Height(m.headersView())
m.UpdateViewport()
}

Expand Down

0 comments on commit c0461cd

Please sign in to comment.