diff --git a/src/textual/widgets/_data_table.py b/src/textual/widgets/_data_table.py index d9ad86181..f82691ce2 100644 --- a/src/textual/widgets/_data_table.py +++ b/src/textual/widgets/_data_table.py @@ -1499,7 +1499,7 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True): meta = self.get_style_at(event.x, event.y).meta if meta: self.cursor_coordinate = Coordinate(meta["row"], meta["column"]) - self._emit_selected_message() + self._post_selected_message() self._scroll_cursor_into_view(animate=True) event.stop() diff --git a/tests/test_data_table.py b/tests/test_data_table.py index 3b8ff25d0..1c5fd35e5 100644 --- a/tests/test_data_table.py +++ b/tests/test_data_table.py @@ -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(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(): """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(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(): text = "Hello"