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

Fix DataTable.update_cell not updating cell immediately #3551

Merged
merged 2 commits into from
Oct 17, 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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

- Fixed issue with LRUCache.discard https://github.com/Textualize/textual/issues/3537
- Fixed issue with `LRUCache.discard` https://github.com/Textualize/textual/issues/3537
- Fixed cache bug with `DataTable.update_cell` https://github.com/Textualize/textual/pull/3551

### Changed

Expand Down
7 changes: 5 additions & 2 deletions src/textual/widgets/_data_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,7 @@ def _update_column_widths(self, updated_cells: set[CellKey]) -> None:
column = self.columns.get(column_key)
if column is None:
continue

console = self.app.console
label_width = measure(console, column.label, 1)
content_width = column.content_width
Expand Down Expand Up @@ -1287,6 +1288,8 @@ def _update_dimensions(self, new_rows: Iterable[RowKey]) -> None:
if row.auto_height:
auto_height_rows.append((row_index, row, cells_in_row))

self._clear_caches()

# 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:
Expand Down Expand Up @@ -1690,9 +1693,9 @@ async def _on_idle(self, _: events.Idle) -> None:
if self._updated_cells:
# Cell contents have already been updated at this point.
# Now we only need to worry about measuring column widths.
updated_columns = self._updated_cells.copy()
updated_cells = self._updated_cells.copy()
self._updated_cells.clear()
self._update_column_widths(updated_columns)
self._update_column_widths(updated_cells)

if self._require_update_dimensions:
# Add the new rows *before* updating the column widths, since
Expand Down
Loading