Fix for interaction between pseudoclasses and widget-level render caches (#2155)

* Using pseudoclass state in DataTable cache keys

* Use full pseudo-class state on tree cache key

* Adding tests for Widget.get_pseudo_class_state

* Test hiding hover cursor when mouse cursor leaves DataTable

* Update CHANGELOG.md
This commit is contained in:
darrenburns
2023-03-28 14:26:24 +01:00
committed by GitHub
parent 73f065bbbd
commit 17c6f3fc2a
6 changed files with 116 additions and 9 deletions

View File

@@ -652,6 +652,23 @@ async def test_hover_coordinate():
assert table.hover_coordinate == Coordinate(1, 0)
async def test_hover_mouse_leave():
"""When the mouse cursor leaves the DataTable, there should be no hover highlighting."""
app = DataTableApp()
async with app.run_test() as pilot:
table = app.query_one(DataTable)
table.add_column("ABC")
table.add_row("123")
await pilot.pause()
assert table.hover_coordinate == Coordinate(0, 0)
# Hover over a cell, and the hover cursor is visible
await pilot.hover(DataTable, offset=Offset(1, 1))
assert table._show_hover_cursor
# Move our cursor away from the DataTable, and the hover cursor is hidden
await pilot.hover(DataTable, offset=Offset(-1, -1))
assert not table._show_hover_cursor
async def test_header_selected():
"""Ensure that a HeaderSelected event gets posted when we click
on the header in the DataTable."""