Skip to content
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

TreeDataProvider: allow selecting a TreeItem without affecting its collapsibleState #34130

Closed
patrys opened this issue Sep 11, 2017 · 31 comments
Closed
Assignees
Labels
feature-request Request for new features or functionality tree-views Extension tree view issues verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@patrys
Copy link

patrys commented Sep 11, 2017

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.

Related: patrys/vscode-code-outline#24

@eamodio
Copy link
Contributor

eamodio commented Sep 11, 2017

Somewhat related to #28632

@weinand weinand added tree-widget Tree widget issues bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority labels Nov 29, 2017
@weinand
Copy link
Contributor

weinand commented Nov 29, 2017

I'm bumping the severity of this since it makes the tree very difficult to use for users.

@weinand weinand added tree-views Extension tree view issues and removed tree-widget Tree widget issues labels Nov 29, 2017
@sandy081 sandy081 added this to the November 2017 milestone Nov 30, 2017
@sandy081
Copy link
Member

sandy081 commented Dec 1, 2017

@weinand May I know the explanation behind its importance?

@patrys @eamodio May I know your expectation in this case. Is your request is to support command only for leaf items?

@weinand
Copy link
Contributor

weinand commented 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).

@weinand weinand added feature-request Request for new features or functionality and removed bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority labels Dec 1, 2017
@patrys
Copy link
Author

patrys commented Dec 1, 2017

@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.

@eamodio
Copy link
Contributor

eamodio commented Dec 1, 2017

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.

@weinand
Copy link
Contributor

weinand commented Dec 1, 2017

@eamodio this is a different issue. You are asking for new API which is already covered by #30288.

@eamodio
Copy link
Contributor

eamodio commented Dec 1, 2017

@weinand very true -- I had originally wanted something like this (where the user controlled it -- I opened #28632), but while I still think it could be useful (for example in GitLens, there are nodes in the tree that both have children and could support a click command themselves) I am worried about the user experience of it. Unless the whole tree behaves the same way, I think it would be strange for a user, if sometimes clicking on a node would expand it and sometimes it might execute a command. Anyway my 2c :)

@patrys
Copy link
Author

patrys commented Dec 1, 2017

I think it would be less surprising if the tree behaved more like native platform trees: usually clicking the name selects/activates items while clicking the chevron or pressing the left/right arrow key collapses/expands the tree.

@sandy081
Copy link
Member

sandy081 commented Dec 3, 2017

@eamodio I agree with your point about consistency. As mentioned, all tree in VS Code are now consistent in how to expand, collapse and selected. In order to separate commands from expand/collapse, how about exposing primary commands on nodes. Eg:

image

I would still allow command on selection which extension authors can decide to have or not to have on leaf nodes and parent nodes.

@sandy081 sandy081 modified the milestones: November 2017, Backlog Dec 4, 2017
@patrys
Copy link
Author

patrys commented Dec 4, 2017

@sandy081 How do you imagine this helping with a code outline type of extension?

@sandy081
Copy link
Member

sandy081 commented Dec 4, 2017

@patrys Agreed, it wont help such extensions. Unfortunately I have to be consistent with current tree behaviour in VS Code.

@zigmondy
Copy link

zigmondy commented Jan 6, 2018

Running into exactly same issue. Can you please prioritize the fix and allow extensions to override the behavior?

oleg-shilo added a commit to oleg-shilo/Favorites.vscode that referenced this issue Feb 13, 2018
- Implemented extending envars in the path of the item definition (Issue #2).
- Implemented 'command-node' for opening parent folder node. To address usability problems caused by VSCode TreeView item defect (microsoft/vscode/issues/34130 and patrys/vscode-code-outline/issues/24)
@TomasHubelbauer
Copy link
Contributor

This is super annoying, I've upvoted both this and #28632 (where the last comment is about awaiting feedback to justify it but three months in VSCodeBot closes down the conversation, oh, how I love VSCodeBot) but feel like I need to vouch for the importance of considering this with a comment, too! The UX on custom trees is extra trippy, certainly unpleasant and I wish it can be rectified.

@patrys
Copy link
Author

patrys commented Apr 27, 2018

I wish I saw #28632 earlier as my extension is affected by it but I guess it could be seen as part of this issue (as there needs to be some folding mechanism).

@sandy081
Copy link
Member

May I know every body asking for this requirement is for Outline views? Or is there some other type of custom view needed this? If so, can you please mention.

Thanks

@TomasHubelbauer
Copy link
Contributor

TomasHubelbauer commented May 15, 2018

My VS Code extension MarkDown To-Do would benefit from this. I need to be able to let the user click a to-do item in my custom tree view to open the corresponding editor and line or let them expand subitems.

@sandy081 sandy081 modified the milestones: Backlog, May 2018 May 15, 2018
@DanTup
Copy link
Contributor

DanTup commented May 15, 2018

@sandy081 Ours is an outline view, however it's kinda specialised (doesn't map directly onto Code like a normal outline, and we'd probably also have a standard outline) if that's relevant (eg., if you built in a standard outline view, I don't think that's solve the problem for us).

@zigmondy
Copy link

zigmondy commented 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
Copy link
Member

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.

@eamodio I suppose your requirement mentioned here is supported now using the existing APIs

@sandy081
Copy link
Member

Here are the two proposals I can think of as solution

  1. Have a tree property like expandOrCollapseOnTwisty and let every node in the tree honours this.

  2. 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
Copy link
Contributor

eamodio commented Jun 20, 2018

@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
Copy link
Member

@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.

  • 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.

@eamodio
Copy link
Contributor

eamodio commented Jun 20, 2018

@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 ;)

@DanTup
Copy link
Contributor

DanTup commented Jun 20, 2018

@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?)

@sandy081 sandy081 added the verification-needed Verification of issue is requested label Jun 26, 2018
@isidorn isidorn added the verified Verification succeeded label Jun 28, 2018
@TomasHubelbauer
Copy link
Contributor

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
Copy link
Member

@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
Copy link

I've also verified in latest version 1.25 and works beautifully!! Thanks for addressing it.

@vscodebot vscodebot bot locked and limited conversation to collaborators Aug 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality tree-views Extension tree view issues verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

8 participants