bubbles icon indicating copy to clipboard operation
bubbles copied to clipboard

fix(table): last row out of viewport

Open System-Glitch opened this issue 11 months ago • 3 comments

When a table cannot display all its rows, the viewport allows scrolling. However, the last row isn't visible.

For example for a table size of 7, the viewport height will be 5 (-2 because of the header). When setting the cursor at position 5, the 6th row should be visible, but isn't. This PR fixes this.

Because cursor is an index (starts at 0), we need to substract 1 to the viewport height to get the correct start position. Otherwise the viewport thinks it can display one more row than it can actually fit when rendering.

System-Glitch avatar Feb 11 '25 14:02 System-Glitch

Wait before merging this. It looks like it introduces undesirable behavior in some cases.

System-Glitch avatar Feb 13 '25 14:02 System-Glitch

Ready for re-review. I removed unecessary code related to the viewport Y offset. I didn't see any difference after removing it because we only render the relevant rows in UpdateViewport() already.

There is one bug remaining: the selector stays at the bottom when moving up. I tested it on master as well just to be sure I didn't introduce it with these changes. I can confirm it's already happening on master.

System-Glitch avatar Feb 13 '25 16:02 System-Glitch

@caarlos0 Can you have another look at it when you have time please?

System-Glitch avatar Jul 03 '25 14:07 System-Glitch