From 49beb3e40715ae2121fcbdf01b94ebc054c0fef2 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Thu, 30 Nov 2023 18:15:39 +0000 Subject: [PATCH 1/2] Force the call to scroll to the region of a node's label Re: https://discord.com/channels/1026214085173461072/1033754296224841768/1179803173498658966 It is possible that the developer may be making a call to scroll to a node, while the scrollbar isn't quite in play yet; without a force to scroll the scroll won't happen. --- 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 c95fb9c792..5a4ca1f9b7 100644 --- a/src/textual/widgets/_tree.py +++ b/src/textual/widgets/_tree.py @@ -904,7 +904,7 @@ def scroll_to_line(self, line: int, animate: bool = True) -> None: """ region = self._get_label_region(line) if region is not None: - self.scroll_to_region(region, animate=animate) + self.scroll_to_region(region, animate=animate, force=True) def scroll_to_node( self, node: TreeNode[TreeDataType], animate: bool = True From 83583d4feb845b0232dfd9901264e87522816f5f Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Thu, 30 Nov 2023 18:32:16 +0000 Subject: [PATCH 2/2] Update the CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e25fbb90e2..9dd8711d50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - `link-hover-background` renamed to `link-background-hover` - `link-hover-color` renamed to `link-color-hover` - `link-hover-style` renamed to `link-style-hover` +- `Tree` now forces a scroll when `scroll_to_node` is called https://github.com/Textualize/textual/pull/3786 ### Added