From 70f173fae8efac392f893d0f4c45082ae2a72520 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Thu, 1 Jun 2023 10:37:39 +0100 Subject: [PATCH 1/3] Ensure a Tree's node is refreshed when the label is changed Fixes #2698 --- src/textual/widgets/_tree.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/textual/widgets/_tree.py b/src/textual/widgets/_tree.py index ef1f25902..83d322905 100644 --- a/src/textual/widgets/_tree.py +++ b/src/textual/widgets/_tree.py @@ -307,6 +307,7 @@ class TreeNode(Generic[TreeDataType]): self._updates += 1 text_label = self._tree.process_label(label) self._label = text_label + self._tree._refresh_node(self) def add( self, From e55ee23eae5b9ae940eecc2d42d70188eec0fc48 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Thu, 1 Jun 2023 10:49:29 +0100 Subject: [PATCH 2/3] Defer the repainting of the node in the tree The previous change actually broke some of the tests in test_disabled.py -- well actually it flat out broke one and caused all the others to run *very* slowly. No clue why though. But thinking about this some more, it does feel like delaying the refresh of the node makes more sense. --- src/textual/widgets/_tree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/textual/widgets/_tree.py b/src/textual/widgets/_tree.py index 83d322905..f4c218cb9 100644 --- a/src/textual/widgets/_tree.py +++ b/src/textual/widgets/_tree.py @@ -307,7 +307,7 @@ class TreeNode(Generic[TreeDataType]): self._updates += 1 text_label = self._tree.process_label(label) self._label = text_label - self._tree._refresh_node(self) + self._tree.call_later(self._tree._refresh_node, self) def add( self, From 3b6f75ce6e93a68c83d0abfc777e0f67d2b89eb8 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Thu, 1 Jun 2023 11:42:19 +0100 Subject: [PATCH 3/3] Update the ChangeLog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a566edf6..679a7b7f0 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/). +## Unreleased + +### Fixed + +- Fixed setting `TreeNode.label` on an existing `Tree` node not immediately https://github.com/Textualize/textual/pull/2713 + ## [0.27.0] - 2023-06-01 ### Fixed