Skip to content

Commit e8151da

Browse files
Fix playlist scrolling showing only one track on page boundary (#185)
Replace paged scrolling with smooth scrolling for song tables. The old paged mode would create incomplete visual pages when API page size didn't divide evenly by visible rows, causing the UI to briefly show just 1 song before loading the next page. Smooth scrolling keeps the selected item visible and scrolls one item at a time, providing a better user experience.
2 parents 8eee1a4 + 7db2ccc commit e8151da

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

src/tui/ui/tables.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,7 @@ fn draw_table(
691691
.map(|height| height as usize)
692692
.unwrap_or(0);
693693

694-
let use_page_scroll = header.id == TableId::Song;
695-
let offset = table_scroll_offset(selected_index, visible_rows, use_page_scroll);
694+
let offset = table_scroll_offset(selected_index, visible_rows);
696695

697696
let rows = items.iter().skip(offset).enumerate().map(|(i, item)| {
698697
let mut formatted_row = item.format.clone();
@@ -773,14 +772,10 @@ fn draw_table(
773772
f.render_widget(table, layout_chunk);
774773
}
775774

776-
fn table_scroll_offset(selected_index: usize, visible_rows: usize, paged: bool) -> usize {
775+
fn table_scroll_offset(selected_index: usize, visible_rows: usize) -> usize {
777776
if visible_rows == 0 {
778777
return 0;
779778
}
780779

781-
if paged {
782-
(selected_index / visible_rows) * visible_rows
783-
} else {
784-
selected_index.saturating_sub(visible_rows.saturating_sub(1))
785-
}
780+
selected_index.saturating_sub(visible_rows.saturating_sub(1))
786781
}

0 commit comments

Comments
 (0)