diff --git a/CHANGELOG.md b/CHANGELOG.md index f08eb77304..d71e5a86d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [7.0.0] - 2026-01-03 + +### Changed + +- `Node.update_node_styles` has grown a `animate` parameter + ## [6.12.0] - 2026-01-02 ### Fixed @@ -3262,6 +3268,7 @@ https://textual.textualize.io/blog/2022/11/08/version-040/#version-040 - New handler system for messages that doesn't require inheritance - Improved traceback handling +[7.0.0]: https://github.com/Textualize/textual/compare/v6.11.0...v7.0.0 [6.11.0]: https://github.com/Textualize/textual/compare/v6.10.0...v6.11.0 [6.10.0]: https://github.com/Textualize/textual/compare/v6.9.0...v6.10.0 [6.9.0]: https://github.com/Textualize/textual/compare/v6.8.0...v6.9.0 diff --git a/pyproject.toml b/pyproject.toml index 212e0eecfa..4f0ba51d03 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "textual" -version = "6.12.0" +version = "7.0.0" homepage = "https://github.com/Textualize/textual" repository = "https://github.com/Textualize/textual" documentation = "https://textual.textualize.io/" diff --git a/src/textual/app.py b/src/textual/app.py index d071562714..a3d91f562d 100644 --- a/src/textual/app.py +++ b/src/textual/app.py @@ -2402,16 +2402,26 @@ def get_child_by_type(self, expect_type: type[ExpectType]) -> ExpectType: """ return self.screen.get_child_by_type(expect_type) - def update_styles(self, node: DOMNode) -> None: + def update_styles(self, node: DOMNode, animate: bool = True) -> None: """Immediately update the styles of this node and all descendant nodes. - Should be called whenever CSS classes / pseudo classes change. + Called by Textual whenever CSS classes / pseudo classes change. For example, when you hover over a button, the :hover pseudo class will be added, and this method is called to apply the corresponding :hover styles. + + Args: + node: Node to update. + animate: Enable animation? """ - descendants = node.walk_children(with_self=True) - self.stylesheet.update_nodes(descendants, animate=True) + if isinstance(node, App): + for screen in reversed(self.screen_stack): + screen.update_node_styles(animate=animate) + if not (screen.is_modal and screen.styles.background.a < 1): + break + else: + descendants = node.walk_children(with_self=True) + self.stylesheet.update_nodes(descendants, animate=animate) def mount( self, diff --git a/src/textual/dom.py b/src/textual/dom.py index 92dfbd5cd6..5e35a4f847 100644 --- a/src/textual/dom.py +++ b/src/textual/dom.py @@ -1733,13 +1733,13 @@ def set_classes(self, classes: str | Iterable[str]) -> Self: self.classes = classes return self - def update_node_styles(self) -> None: + def update_node_styles(self, animate: bool = True) -> None: """Request an update of this node's styles. Called by Textual whenever CSS classes / pseudo classes change. """ try: - self.app.update_styles(self) + self.app.update_styles(self, animate=animate) except NoActiveAppError: pass diff --git a/src/textual/screen.py b/src/textual/screen.py index a92776d659..cc1ef9fe28 100644 --- a/src/textual/screen.py +++ b/src/textual/screen.py @@ -1441,8 +1441,7 @@ def _on_screen_resume(self) -> None: if self.is_attached: self._compositor_refresh() - if self.stack_updates == 1: - self.app.stylesheet.update(self) + self.update_node_styles(animate=False) self._refresh_layout(size) self.refresh()