Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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/"
Expand Down
18 changes: 14 additions & 4 deletions src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/textual/dom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions src/textual/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Loading