Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(table): allow page up/down in table #4

Closed
wants to merge 1 commit into from

Conversation

orhun
Copy link
Member

@orhun orhun commented Feb 12, 2023

NOTE FOR IMPLEMENTER: Please read the following before picking this up for implementation:

Upstream: #246

Hi!

I started playing with the table example and though that for bigger tables it would be nice to be able to scroll the data a page at a time, so I altered the Table widget's TableState to store a page size for the table and its render function to update this at the relevant point. I have also updated the example for the Table widget to use this.

Let me know if you think this is a good addition or any other feedback. 😁

@mindoodoo mindoodoo added the Type: Enhancement New feature or request label Feb 14, 2023
joshka pushed a commit to joshka/ratatui that referenced this pull request Apr 28, 2023
@joshka joshka added the Type: Imported from tui-rs This issue / PR was Imported from tui-rs - kept for posterity / ease of finding historical ideas label May 5, 2023
@joshka joshka force-pushed the 246/demonstrate-paging-in-table branch from 5d813f6 to 14fed0c Compare May 5, 2023 22:45
@joshka
Copy link
Member

joshka commented May 5, 2023

Rebased on main and this runs. This works the same as the implementation in tui for this change did, but the behavior seems a little odd.

asciicast

Hitting page down when row 0 is selected with rows 0-13 showing on the screen makes item 1-14 shown on the screen with row 14 selected (and similarly page up when row 14 is selected goes to 0.

I think the more obvious behavior might to display rows 14-27 when paging down and have 14 be the selected row.

Additionally, the wrap around behavior seems odd. Going page up from row 0 shows rows 73 to 86, numerically correct, but would be odd from a user's perspective as it makes rows 87-99 effectively invisible.

Or put another way:

  • Page down from 0 selected showing 0-13 should show 14-27 with 14 selected at the top, not 1-14 with 14 selected at the bottom.
  • Page up from 0 should show 86-99, with 86 selected at the top.

I might be wrong on this though, so please feel free to correct me, but it took a bit of effort to understand what was going on with this and build a mental model just from using it where the selected item would end up.

I think this is a reasonable feature if the behavior is fixed to properly show all rows without skipping displaying any, and by scrolling by a page rather than an index.

Pinging @Eosis to see if they want to pick this up and complete the feature (and marking it as up for grabs / draft if not)

@joshka joshka added the Status: Available An issue or PR that is ready to implement / partially implemented and up for grabs label May 5, 2023
@joshka joshka marked this pull request as draft May 5, 2023 22:59
- Add a page_size to the Table widget's state that is populated when the
 table is rendered and allows users to scroll the cursor in the table
 much more quickly.

- Alter the table example to demonstrate potential paging behaviour
 - Add new next and previous page functions to demonstrate moving a
  selection by page.
 - Automatically generate the data for the table as a Vec<Vec<String>>.
@joshka joshka force-pushed the 246/demonstrate-paging-in-table branch from 14fed0c to 00b4b7a Compare May 6, 2023 01:50
@joshka joshka changed the title Demonstrate paging in table feat(table): allow page up/down in table May 7, 2023
@joshka
Copy link
Member

joshka commented Dec 13, 2023

This issue was closed due to it becoming stale. Feel free to reopen and work on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Available An issue or PR that is ready to implement / partially implemented and up for grabs Type: Enhancement New feature or request Type: Imported from tui-rs This issue / PR was Imported from tui-rs - kept for posterity / ease of finding historical ideas
Projects
Status: Done
Status: Feature
Development

Successfully merging this pull request may close these issues.

3 participants