Skip to content

Commit

Permalink
Remember Tree.root's expanded state when performing Tree.clear
Browse files Browse the repository at this point in the history
See #3557.
  • Loading branch information
davep authored and willmcgugan committed Jan 11, 2024
1 parent a1aa12a commit 45bf538
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/textual/widgets/_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,13 +717,14 @@ def clear(self) -> Self:
self._current_id = 0
root_label = self.root._label
root_data = self.root.data
root_expanded = self.root.is_expanded
self.root = TreeNode(
self,
None,
self._new_id(),
root_label,
root_data,
expanded=True,
expanded=root_expanded,
)
self._updates += 1
self.refresh()
Expand Down

0 comments on commit 45bf538

Please sign in to comment.