Skip to content

Commit b160961

Browse files
committed
fix for child color refresh
1 parent c20bf66 commit b160961

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/textual/css/_style_properties.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -794,9 +794,8 @@ def __set__(self, obj: StylesBase, names: str | tuple[str] | None = None):
794794
class ColorProperty:
795795
"""Descriptor for getting and setting color properties."""
796796

797-
def __init__(self, default_color: Color | str, background: bool = False) -> None:
797+
def __init__(self, default_color: Color | str) -> None:
798798
self._default_color = Color.parse(default_color)
799-
self._is_background = background
800799

801800
def __set_name__(self, owner: StylesBase, name: str) -> None:
802801
self.name = name
@@ -830,11 +829,10 @@ def __set__(self, obj: StylesBase, color: Color | str | None):
830829
_rich_traceback_omit = True
831830
if color is None:
832831
if obj.clear_rule(self.name):
833-
obj.refresh(children=self._is_background)
832+
obj.refresh(children=True)
834833
elif isinstance(color, Color):
835834
if obj.set_rule(self.name, color):
836-
obj.refresh(children=self._is_background)
837-
835+
obj.refresh(children=True)
838836
elif isinstance(color, str):
839837
alpha = 1.0
840838
parsed_color = Color(255, 255, 255)
@@ -855,8 +853,9 @@ def __set__(self, obj: StylesBase, color: Color | str | None):
855853
),
856854
)
857855
parsed_color = parsed_color.with_alpha(alpha)
856+
858857
if obj.set_rule(self.name, parsed_color):
859-
obj.refresh(children=self._is_background)
858+
obj.refresh(children=True)
860859
else:
861860
raise StyleValueError(f"Invalid color value {color}")
862861

src/textual/css/styles.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ class StylesBase(ABC):
214214

215215
auto_color = BooleanProperty(default=False)
216216
color = ColorProperty(Color(255, 255, 255))
217-
background = ColorProperty(Color(0, 0, 0, 0), background=True)
217+
background = ColorProperty(Color(0, 0, 0, 0))
218218
text_style = StyleFlagsProperty()
219219

220220
opacity = FractionalProperty()
@@ -421,7 +421,7 @@ def refresh(self, *, layout: bool = False, children: bool = False) -> None:
421421
422422
Args:
423423
layout (bool, optional): Also require a layout. Defaults to False.
424-
children (bool, opional): Also refresh children. Defaults to False.
424+
children (bool, optional): Also refresh children. Defaults to False.
425425
"""
426426

427427
@abstractmethod

0 commit comments

Comments
 (0)