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 - allow the cursor to enter fixed columns #1799

Merged
merged 4 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- `DOMNode.tree` now displays simple DOM structure only https://github.com/Textualize/textual/pull/1778
- `App.install_screen` now returns None rather than AwaitMount https://github.com/Textualize/textual/pull/1778
- `DOMNode.children` is now a simple sequence, the NodesList is exposed as `DOMNode._nodes` https://github.com/Textualize/textual/pull/1778
- `DataTable` cursor can now enter fixed columns https://github.com/Textualize/textual/pull/1799

### Fixed

Expand Down
8 changes: 2 additions & 6 deletions src/textual/widgets/_data_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ def _clamp_cursor_coordinate(self, coordinate: Coordinate) -> Coordinate:
"""Clamp a coordinate such that it falls within the boundaries of the table."""
row, column = coordinate
row = clamp(row, 0, self.row_count - 1)
column = clamp(column, self.fixed_columns, len(self.columns) - 1)
column = clamp(column, 0, len(self.columns) - 1)
return Coordinate(row, column)

def watch_cursor_type(self, old: str, new: str) -> None:
Expand Down Expand Up @@ -1590,11 +1590,7 @@ def _get_fixed_offset(self) -> Spacing:
that is occupied by fixed rows and columns respectively. Fixed rows and columns
are rows and columns that do not participate in scrolling."""
top = self.header_height if self.show_header else 0
top += sum(
self.rows[self._row_locations.get_key(row_index)].height
for row_index in range(self.fixed_rows)
if row_index in self.rows
)
top += sum(row.height for row in self.ordered_rows[: self.fixed_rows])
left = sum(
column.render_width for column in self.ordered_columns[: self.fixed_columns]
)
Expand Down
Loading