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

DataTable navigation updates #4633

Merged
merged 11 commits into from
Jun 11, 2024
Merged

DataTable navigation updates #4633

merged 11 commits into from
Jun 11, 2024

Conversation

darrenburns
Copy link
Member

@darrenburns darrenburns commented Jun 10, 2024

Updates the pageup/pagedown behaviour in the DataTable to match the TextArea widget (and Google Sheets!).
Adds some extra bindings to DataTable, particularly around horizontal navigation.

@darrenburns darrenburns marked this pull request as ready for review June 11, 2024 11:53
@darrenburns darrenburns changed the title Datatable fixes Fix DataTable pageup/pagedown behaviour Jun 11, 2024
@darrenburns darrenburns marked this pull request as draft June 11, 2024 11:54
Comment on lines +219 to +228
Binding("up,k", "cursor_up", "Cursor Up", show=False),
Binding("down,j", "cursor_down", "Cursor Down", show=False),
Binding("right,l", "cursor_right", "Cursor Right", show=False),
Binding("left,h", "cursor_left", "Cursor Left", show=False),
Binding("pageup", "page_up", "Page Up", show=False),
Binding("pagedown", "page_down", "Page Down", show=False),
Binding("g", "scroll_top", "Top", show=False),
Binding("G", "scroll_bottom", "Bottom", show=False),
Binding("home", "scroll_home", "Home", show=False),
Binding("end", "scroll_end", "End", show=False),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some common bindings, particularly for horizontal navigation which I found to be lacking when using the keyboard.

Comment on lines +50 to +51
Binding("ctrl+pageup", "page_left", "Page Left", show=False),
Binding("ctrl+pagedown", "page_right", "Page Right", show=False),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Horizontally navigating widgets can be a bit slow when using the keyboard.

If you hold ctrl and use the scroll wheel, it applies it in the horizontal direction. So, I thought maybe we could have that apply to pageup/pagedown too.

Comment on lines +2567 to +2583
def action_scroll_home(self) -> None:
"""Move the cursor and scroll to the leftmost column."""
self._set_hover_cursor(False)
cursor_type = self.cursor_type
if self.show_cursor and (cursor_type == "cell" or cursor_type == "column"):
self.move_cursor(column=0)
else:
self.scroll_x = 0

def action_scroll_end(self) -> None:
"""Move the cursor and scroll to the rightmost column."""
self._set_hover_cursor(False)
cursor_type = self.cursor_type
if self.show_cursor and (cursor_type == "cell" or cursor_type == "column"):
self.move_cursor(column=len(self.columns) - 1)
else:
self.scroll_x = self.max_scroll_x
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quickly jumping to the first/last cell in a row. Also intended to improve horizontal navigation with the keyboard.

@darrenburns darrenburns changed the title Fix DataTable pageup/pagedown behaviour DataTable navigation updates Jun 11, 2024
@darrenburns darrenburns marked this pull request as ready for review June 11, 2024 12:08
@darrenburns darrenburns requested a review from willmcgugan June 11, 2024 12:08
@darrenburns darrenburns merged commit 2618bae into main Jun 11, 2024
20 checks passed
@darrenburns darrenburns deleted the datatable-fixes branch June 11, 2024 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants