diff --git a/src/textual/css/styles.py b/src/textual/css/styles.py index 211432aadb..8ba4685a0f 100644 --- a/src/textual/css/styles.py +++ b/src/textual/css/styles.py @@ -975,7 +975,10 @@ def _update_rules( changes = updates + removed if not changes: return False - geometry = any( + # Detached styles normalize rules (including mount's prepared copy) + # but have no node geometry to invalidate. Keep validation and rule + # publication intact; acquire placement effects only for their owner. + geometry = self.node is not None and any( descriptor.affects_geometry(previous, value) for descriptor, key, previous, value in changes ) diff --git a/tests/css/test_stylesheet.py b/tests/css/test_stylesheet.py index f437f935ba..4925e221e9 100644 --- a/tests/css/test_stylesheet.py +++ b/tests/css/test_stylesheet.py @@ -100,7 +100,8 @@ async def test_style_batch_keeps_child_damage_separate_and_flushes_interrupted_e parent.styles.refresh(layout=True) with parent.styles.batch_update(): parent.styles.color = "green" - refresh.assert_called_once_with(layout=False, repaint=True) + refresh.assert_called_once_with(repaint=True) + assert not child._layout_required assert child.rich_style.color == Color.parse("green").rich_color with pytest.raises(StyleValueError), parent.styles.batch_update(): parent.styles.color = "red"