fix(table): substract headers Y size from the total table size
I spotted a bug while creating a table and viewport side by side. Even though they have set the exact height value, both have different sizes. While debugging, it came out that we only passed it down to the nested viewport component by setting table height, but the render method looks like this.
// View renders the component.
func (m Model) View() string {
return m.headersView() + "\n" + m.viewport.View()
}
So, the total height of the table is the sum of the viewport's height and the headers' height. I have simply subtracted headings Y size from the viewport height, and it looks like this fixed the issue.
Okay, it does not work as I expected. I will dig it up latter
Okay, first of all, I changed GetFrameSize to GetVerticalFrameSize since X calculations are not helpful here.
Secondly, I realized that GetVerticalFrameSize does not return the total height of the component - just the sum of margins, padding, and borders. So, besides subtracting that one bad boi, I have to get in content height. I have used lipgloss.Height(m.headersView()) in the SetHeight function. I am unsure if this approach is good since it renders it twice (in SetHeight and View functions).
What is worth mentioning is that the content height, with the current implementation, is always 0 or 1 due to truncating the header text. But I keep in mind that if https://github.com/charmbracelet/bubbles/pull/433 will merge, I would also like to make a similar one for that part. That's why I decided to calculate that value here.
Update once again:
During testing on a local setup, it came out that GetVerticalFrameSize is not necessary at all. But would great if somebody could confirm that
@meowgorithm @muesli i do not who to ping
Hey @prgres, thanks so much for the PR ❤️
Thanks for the PR @prgres, I merged this one since it's a simple bug fix but just to give you a heads up, we're going to swap out the entire implementation for the Lip Gloss table renderer:
https://github.com/charmbracelet/lipgloss/releases/tag/v0.9.0