diff --git a/src/textual/css/stylesheet.py b/src/textual/css/stylesheet.py index 10d3a22cc..e92a87579 100644 --- a/src/textual/css/stylesheet.py +++ b/src/textual/css/stylesheet.py @@ -408,6 +408,7 @@ class Stylesheet: component_classes = node._get_component_classes() if component_classes: + # Create virtual nodes that exist to extract styles refresh_node = False old_component_styles = node._component_styles.copy() node._component_styles.clear() @@ -419,6 +420,7 @@ class Stylesheet: not refresh_node and old_component_styles.get(component) != virtual_node.styles ): + # If the styles have changed we want to refresh the node refresh_node = True node._component_styles[component] = virtual_node.styles if refresh_node: diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py index 83253aa85..05d48a5fe 100644 --- a/tests/snapshot_tests/test_snapshots.py +++ b/tests/snapshot_tests/test_snapshots.py @@ -213,7 +213,7 @@ def test_demo(snap_compare): """Test the demo app (python -m textual)""" assert snap_compare( Path("../../src/textual/demo.py"), - press=["down", "down", "down", "_"], + press=["down", "down", "down"], terminal_size=(100, 30), ) @@ -238,6 +238,4 @@ def test_disabled_widgets(snap_compare): def test_focus_component_class(snap_compare): - assert snap_compare( - SNAPSHOT_APPS_DIR / "focus_component_class.py", press=["tab", "_"] - ) + assert snap_compare(SNAPSHOT_APPS_DIR / "focus_component_class.py", press=["tab"])