You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TreeDataProvider: allow selecting a TreeItem without affecting its collapsibleState #34130
Currently clicking an item will both select it and change its expanded/collapsed state. This results in very weird UX as you need to click the items to interact with them.
I have an extension that provides a tree outline of the currently opened file and clicking a class name will currently select that class in the editor and at the same time expand/collapse its children in the tree view.
Today I learned that all VS Code trees behave like this.
So all VS Code trees collapse/expand when a node is selected.
For the standard VS Code trees (e.g file explorer) this is not a problem because the only purpose of selecting a non-leaf node is to expand or collapse it, so selecting a non-leaf node is not really needed because the node itself is never fed into an editor.
For custom trees the story is not so clear:
In a custom tree a non-leaf node might feed into an editor and expanding its children could be an expensive operation. So it is questionable whether both purposes should be coupled into one gesture.
If a user only wants to select the node in order to open it in an editor, this is not possible without expanding all children at the same time.
Since the current behaviour is consistent with the other VS Code trees, I think this is not a bug but a feature and we can remove the "important" flag (and there is no need to implement this feature in this milestone).
Sandeep Somavarapu (@sandy081) My extension shows a code outline so containers can be classes while leaves are functions, I'd very much like to support commands at all tree levels in a way that does not affect the tree state.
For me, it is less about the user clicking on an item, and more about having an api (way) to not only set focus to the tree, but select an item -- and ideally control whether or not it expands when selected via that api.
Eric Amodio (@eamodio) I suppose your requirement mentioned here is supported now using the existing APIs
Sandeep Somavarapu (@sandy081) AFAIK there still isn't an api to select an item in the tree and have it expand or collapse though right?
With regards to the proposed, I like #2 -- implicit and imo will do what you want (even though the experience is inconsistent it could be desirable depending on the usage).
If a node provides command, then node is expanded/collapsed only when user clicks on the twisty. Also, command will not be executed when user clicks on twisty.
Reacted by Eric Amodio, Danny Tuppeny and Tomáš Hübelbauer
Sandeep Somavarapu (@sandy081) We talked about it back during the reveal api discussion, but I don't have a strong enough need for it at this point, so I'll leave it be ;)
Eric Amodio (@eamodio) I haven't tried it, but does changing collapsibleState and then fire an update for the node work? (it's not nice, sure, but if it works?)
Activity
eamodio commentedon Sep 11, 2017
Somewhat related to #28632
weinand commentedon Nov 29, 2017
I'm bumping the severity of this since it makes the tree very difficult to use for users.
sandy081 commentedon Dec 1, 2017
Andre Weinand (@weinand) May I know the explanation behind its importance?
Patryk Zawadzki (@patrys) Eric Amodio (@eamodio) May I know your expectation in this case. Is your request is to support command only for leaf items?
weinand commentedon Dec 1, 2017
Today I learned that all VS Code trees behave like this.
So all VS Code trees collapse/expand when a node is selected.
For the standard VS Code trees (e.g file explorer) this is not a problem because the only purpose of selecting a non-leaf node is to expand or collapse it, so selecting a non-leaf node is not really needed because the node itself is never fed into an editor.
For custom trees the story is not so clear:
In a custom tree a non-leaf node might feed into an editor and expanding its children could be an expensive operation. So it is questionable whether both purposes should be coupled into one gesture.
If a user only wants to select the node in order to open it in an editor, this is not possible without expanding all children at the same time.
Since the current behaviour is consistent with the other VS Code trees, I think this is not a bug but a feature and we can remove the "important" flag (and there is no need to implement this feature in this milestone).
patrys commentedon Dec 1, 2017
Sandeep Somavarapu (@sandy081) My extension shows a code outline so containers can be classes while leaves are functions, I'd very much like to support commands at all tree levels in a way that does not affect the tree state.
26 remaining items
zigmondy commentedon Jun 6, 2018
Hopefully the capability to suppress collapse on click is built some day. VS code tree view extension feels so limited because of this issue :( !!!
sandy081 commentedon Jun 19, 2018
Eric Amodio (@eamodio) I suppose your requirement mentioned here is supported now using the existing APIs
sandy081 commentedon Jun 19, 2018
Here are the two proposals I can think of as solution
Have a tree property like
expandOrCollapseOnTwistyand let every node in the tree honours this.If a tree node has a command, then Expand/Collapse it only when user clicks on twisty, otherwise do it when user clicks any where on the node.
eamodio commentedon Jun 20, 2018
Sandeep Somavarapu (@sandy081) AFAIK there still isn't an api to select an item in the tree and have it expand or collapse though right?
With regards to the proposed, I like #2 -- implicit and imo will do what you want (even though the experience is inconsistent it could be desirable depending on the usage).
sandy081 commentedon Jun 20, 2018
Eric Amodio (@eamodio) There is reveal API to select, but not to expand or collapse. Is there an issue you opened where we can discuss about it?
I also liked #2 and implemented.
eamodio commentedon Jun 20, 2018
Sandeep Somavarapu (@sandy081) We talked about it back during the
revealapi discussion, but I don't have a strong enough need for it at this point, so I'll leave it be ;)DanTup commentedon Jun 20, 2018
Eric Amodio (@eamodio) I haven't tried it, but does changing
collapsibleStateand then fire an update for the node work? (it's not nice, sure, but if it works?)TomasHubelbauer commentedon Jul 9, 2018
This has not shipped as a part of the June milestone, right? Can the milestone be updated to the next one in case this is projected to land in it?
sandy081 commentedon Jul 10, 2018
Tomáš Hübelbauer (@TomasHubelbauer) This is fixed in June milestone and is available in the latest 1.25 (June) stable release.
May I know why do you think so?
zigmondy commentedon Jul 10, 2018
I've also verified in latest version 1.25 and works beautifully!! Thanks for addressing it.