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 improvements (and more) #1547

Merged
merged 58 commits into from
Jan 18, 2023
Merged

DataTable improvements (and more) #1547

merged 58 commits into from
Jan 18, 2023

Conversation

darrenburns
Copy link
Member

@darrenburns darrenburns commented Jan 11, 2023

Added

  • Different cursor types: cell (pre-existing), row, column, none. If you want no cursor at all, you can use the "none" cursor.
    • Scrolling (with arrow keys) perpendicular to the cursor type will move the cursor.
    • Scrolling (with arrow keys) parallel to the cursor type will scroll as normal without shifting the cursor.
    • When "none" cursor is used, arrow keys are used just for scrolling.
  • Ability to switch cursor off table.show_cursor = False. This will hide the cursor. The cursor state is retained when re-enabled. When you disable it, scrolling with arrow keys works as normal. When you re-enable it, the cursor will be scrolled to.
  • Hover cursor will now only become visible when you interact with the table using the mouse. It'll hide again when you use the keyboard.
  • Events for row/col/cell highlighting and selection.
  • Improving reactive tests - some of them had redundant code or things commented out that were previously broken.
  • Extract Coord class into own module for reuse, and rename it to Coordinate.
datatable-cursors-16jan23.mov

Issues encountered

  • show_cursor was part of the API but not actually implemented.
  • When fixed columns are used, the cursor isn't visible until you move it.
  • Component style for datatable--even-row doesn't apply at all (but odd works).
  • Crash if number of fixed_columns is equal to number of columns (presumably when greater too).
  • (Possibly missing API) We need to clamp cursor position when number of fixed_columns changes, so we clamp and then assign it. Since we assign it, it triggers the validator which clamps it again, repeating the work.
  • Vertical scrollbar doesn't update when show_header set to False.

Please review the following checklist.

  • Docstrings on all new or modified functions / classes
  • Updated documentation
  • Updated CHANGELOG.md (where appropriate)

@darrenburns darrenburns changed the title DataTable improvements DataTable improvements (and more) Jan 16, 2023
Comment on lines +135 to +136
"datatable--cursor-fixed",
"datatable--highlight-fixed",
Copy link
Member Author

Choose a reason for hiding this comment

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

We'll probably need to change the names of these when we do "labelled" rows/columns - the fixed/header concepts are a little conflated at the moment.

cursor_cell: Reactive[Coord] = Reactive(Coord(0, 0), repaint=False)
hover_cell: Reactive[Coord] = Reactive(Coord(0, 0), repaint=False)
cursor_cell: Reactive[Coordinate] = Reactive(
Coordinate(0, 0), repaint=False, always_update=True
Copy link
Member Author

Choose a reason for hiding this comment

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

always_update is required as sometimes we need to force validation via self.cursor_cell = self.cursor_cell.

@darrenburns darrenburns marked this pull request as ready for review January 17, 2023 15:13
Copy link
Collaborator

@willmcgugan willmcgugan left a comment

Choose a reason for hiding this comment

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

LGTM

We should think about an example that uses the data-table. One for another PR.

@willmcgugan willmcgugan merged commit a70520f into main Jan 18, 2023
@willmcgugan willmcgugan deleted the datatable-events branch January 18, 2023 10:01
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.

4 participants