Skip to content

Commit

Permalink
Auto-height table repopulate fix (Textualize#4992)
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenburns authored Sep 13, 2024
1 parent daab5c2 commit 769c7f6
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Fixed `RichLog` writing at wrong width when `write` occurs before width is known (e.g. in `compose` or `on_mount`) https://github.com/Textualize/textual/pull/4978
- Fixed `RichLog.write` incorrectly shrinking width to `RichLog.min_width` when `shrink=True` (now shrinks to fit content area instead) https://github.com/Textualize/textual/pull/4978
- Fixed flicker when setting `dark` reactive on startup https://github.com/Textualize/textual/pull/4989
- Fixed `DataTable` cached height issue on re-populating the table when using auto-height rows https://github.com/Textualize/textual/pull/4992

## [0.79.1] - 2024-08-31

Expand Down
5 changes: 5 additions & 0 deletions src/textual/widgets/_data_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,7 @@ def _y_offsets(self) -> list[tuple[RowKey, int]]:
for row in self.ordered_rows:
y_offsets += [(row.key, y) for y in range(row.height)]
self._offset_cache[self._update_count] = y_offsets

return y_offsets

@property
Expand Down Expand Up @@ -1397,6 +1398,7 @@ def _update_dimensions(self, new_rows: Iterable[RowKey]) -> None:
# If there are rows that need to have their height computed, render them correctly
# so that we can cache this rendering for later.
if auto_height_rows:
self._offset_cache.clear()
render_cell = self._render_cell # This method renders & caches.
should_highlight = self._should_highlight
cursor_type = self.cursor_type
Expand Down Expand Up @@ -1451,6 +1453,9 @@ def _update_dimensions(self, new_rows: Iterable[RowKey]) -> None:
]
)

self._line_cache.clear()
self._styles_cache.clear()

data_cells_width = sum(
column.get_render_width(self) for column in self.columns.values()
)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 769c7f6

Please sign in to comment.