Skip to content

Commit

Permalink
Scroll datatable cursor after refresh, since new rows may be measured…
Browse files Browse the repository at this point in the history
… in on_idle
  • Loading branch information
darrenburns committed Oct 17, 2023
1 parent 4b5556c commit 23b9ac6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/textual/widgets/_data_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1116,9 +1116,10 @@ def move_cursor(
cursor_row = row
if column is not None:
cursor_column = column

destination = Coordinate(cursor_row, cursor_column)
self.cursor_coordinate = destination
self._scroll_cursor_into_view(animate=animate)
self.call_after_refresh(self._scroll_cursor_into_view, animate=animate)

def _highlight_coordinate(self, coordinate: Coordinate) -> None:
"""Apply highlighting to the cell at the coordinate, and post event."""
Expand Down Expand Up @@ -1615,9 +1616,11 @@ def remove_row(self, row_key: RowKey | str) -> None:
Raises:
RowDoesNotExist: If the row key does not exist.
"""

if row_key not in self._row_locations:
raise RowDoesNotExist(f"Row key {row_key!r} is not valid.")

self._new_rows.discard(row_key)
self._require_update_dimensions = True
self.check_idle()

Expand Down

0 comments on commit 23b9ac6

Please sign in to comment.