Skip to content

Commit

Permalink
fix: Table offset should not be negative (#3049)
Browse files Browse the repository at this point in the history
fixes #2857
  • Loading branch information
cmitsakis authored and andydotxyz committed May 26, 2023
1 parent a608613 commit e5198de
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions widget/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ func (t *Table) ScrollToBottom() {
rows, _ := t.Length()
cellY, cellHeight := t.findY(rows - 1)
y := cellY + cellHeight - t.scroll.Size().Height
if y <= 0 {
return
}

t.scroll.Offset.Y = y
t.offset.Y = y
Expand Down Expand Up @@ -265,6 +268,9 @@ func (t *Table) ScrollToTrailing() {
_, cols := t.Length()
cellX, cellWidth := t.findX(cols - 1)
scrollX := cellX + cellWidth - t.scroll.Size().Width
if scrollX <= 0 {
return
}

t.scroll.Offset.X = scrollX
t.offset.X = scrollX
Expand Down

0 comments on commit e5198de

Please sign in to comment.