Fix attribute error with emit being remove, check ordered_rows is correct after sort

This commit is contained in:
Darren Burns
2023-02-08 13:20:53 +00:00
parent 20b8782a5d
commit 54a29dd664
2 changed files with 9 additions and 1 deletions

View File

@@ -1499,7 +1499,7 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
meta = self.get_style_at(event.x, event.y).meta meta = self.get_style_at(event.x, event.y).meta
if meta: if meta:
self.cursor_coordinate = Coordinate(meta["row"], meta["column"]) self.cursor_coordinate = Coordinate(meta["row"], meta["column"])
self._emit_selected_message() self._post_selected_message()
self._scroll_cursor_into_view(animate=True) self._scroll_cursor_into_view(animate=True)
event.stop() event.stop()

View File

@@ -579,6 +579,10 @@ async def test_sort_coordinate_and_key_access():
assert table.get_value_at(Coordinate(1, 0)) == 2 assert table.get_value_at(Coordinate(1, 0)) == 2
assert table.get_value_at(Coordinate(2, 0)) == 3 assert table.get_value_at(Coordinate(2, 0)) == 3
assert table.ordered_rows[0].key == row_one
assert table.ordered_rows[1].key == row_two
assert table.ordered_rows[2].key == row_three
async def test_sort_reverse_coordinate_and_key_access(): async def test_sort_reverse_coordinate_and_key_access():
"""Ensure that, after sorting, that coordinates and cell keys """Ensure that, after sorting, that coordinates and cell keys
@@ -608,6 +612,10 @@ async def test_sort_reverse_coordinate_and_key_access():
assert table.get_value_at(Coordinate(1, 0)) == 2 assert table.get_value_at(Coordinate(1, 0)) == 2
assert table.get_value_at(Coordinate(2, 0)) == 1 assert table.get_value_at(Coordinate(2, 0)) == 1
assert table.ordered_rows[0].key == row_three
assert table.ordered_rows[1].key == row_two
assert table.ordered_rows[2].key == row_one
def test_key_equals_equivalent_string(): def test_key_equals_equivalent_string():
text = "Hello" text = "Hello"