Skip to content

Commit 769c7f6

Browse files
authored
Auto-height table repopulate fix (Textualize#4992)
1 parent daab5c2 commit 769c7f6

File tree

4 files changed

+203
-1
lines changed

4 files changed

+203
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3030
- 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
3131
- 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
3232
- Fixed flicker when setting `dark` reactive on startup https://github.com/Textualize/textual/pull/4989
33+
- Fixed `DataTable` cached height issue on re-populating the table when using auto-height rows https://github.com/Textualize/textual/pull/4992
3334

3435
## [0.79.1] - 2024-08-31
3536

src/textual/widgets/_data_table.py

+5
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,7 @@ def _y_offsets(self) -> list[tuple[RowKey, int]]:
818818
for row in self.ordered_rows:
819819
y_offsets += [(row.key, y) for y in range(row.height)]
820820
self._offset_cache[self._update_count] = y_offsets
821+
821822
return y_offsets
822823

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

1456+
self._line_cache.clear()
1457+
self._styles_cache.clear()
1458+
14541459
data_cells_width = sum(
14551460
column.get_render_width(self) for column in self.columns.values()
14561461
)

0 commit comments

Comments
 (0)