-
Notifications
You must be signed in to change notification settings - Fork 829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Selecting the root of a Tree does not highlight descendants. #2397
Comments
The expected behaviour is to highlight all descendants, including the root. Let's fix that first. |
Tree
While building up some test code for this, I think I've either uncovered three problems here, or three symptoms of an underlying problem. Using this code: from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import Header, Footer, Tree
from textual.widgets.tree import TreeNode
class TreeLinesTestApp( App[ None ] ):
CSS = """
Tree {
border: round red;
}
Tree:focus {
border: double green;
}
"""
def compose( self ) -> ComposeResult:
yield Header()
with Horizontal():
yield Tree("Root", id="root")
yield Tree("Root", id="no-root")
yield Footer()
def populate( self, node: TreeNode, limit: int=3 ) -> Tree:
for n in range( limit ):
self.populate( node.add( str( n ) ), limit-1 )
return node.tree
def on_mount( self ) -> None:
self.query_one( "#no-root", Tree ).show_root = False
self.populate( self.query_one( "#root", Tree ).root ).root.expand_all()
self.populate( self.query_one( "#no-root", Tree ).root ).root.expand_all()
if __name__ == "__main__":
TreeLinesTestApp().run() I get this effect: Screen.Recording.2023-05-03.at.14.15.37.movNote the following things:
|
Should also be noted that, within the bounds of what it means to hover, the same issue affects the style of lines and mouse hover too. |
Possibly related, or at least related to one of the effects shown above: the shows-root Need to keep this in mind as I dive deeper. |
Just to clarify for myself here, as far as I can tell there are two distinct issues at play here:
It's been a bit too easy to be distracted by one while trying to reason about the other. |
Rather than always start at the root, the code should start at the beginning of the path. See Textualize#2397.
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
The
Tree
widget will highlight the lines that descend from the selected node, but at the moment it doesn't seem to do it from the top level. For example, consider this:where the topmost node is selected but no lines are highlighted, against this:
where a node one level down is highlighted and all the line below are highlighted.
We should review this, decide exactly what is supposed to happen, and have it be the same for all levels.
Also @darrenburns has raised the extra question of if it might be an idea to have it such that it only highlights the immediate lines vs all the lines in the tree below.
The text was updated successfully, but these errors were encountered: