mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-05 04:36:07 +00:00
fix(table): add fixes to pageup/pagedown
This commit is contained in:
+11
-5
@@ -408,9 +408,7 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
|
||||
if !m.focus {
|
||||
return m, nil
|
||||
}
|
||||
table := m.table.String()
|
||||
// XXX: make this not hard coded?
|
||||
height := lipgloss.Height(table) - 6
|
||||
height := m.table.VisibleRows() - 1
|
||||
|
||||
switch msg := msg.(type) {
|
||||
case tea.KeyPressMsg:
|
||||
@@ -420,9 +418,17 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
|
||||
case key.Matches(msg, m.KeyMap.LineDown):
|
||||
m.MoveDown(1)
|
||||
case key.Matches(msg, m.KeyMap.PageUp):
|
||||
m.MoveUp(height)
|
||||
if m.cursor > m.table.FirstVisibleRowIndex() {
|
||||
m.SetCursor(m.table.FirstVisibleRowIndex())
|
||||
} else {
|
||||
m.MoveUp(height)
|
||||
}
|
||||
case key.Matches(msg, m.KeyMap.PageDown):
|
||||
m.MoveDown(height)
|
||||
if m.cursor < m.table.LastVisibleRowIndex() {
|
||||
m.SetCursor(m.table.LastVisibleRowIndex())
|
||||
} else {
|
||||
m.MoveDown(height)
|
||||
}
|
||||
case key.Matches(msg, m.KeyMap.HalfPageUp):
|
||||
m.MoveUp(height / 2) //nolint:mnd
|
||||
case key.Matches(msg, m.KeyMap.HalfPageDown):
|
||||
|
||||
Reference in New Issue
Block a user