Skip to content

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

Closed

Description

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

Activity

  1. eamodio commented on Sep 11, 2017

    @eamodio
    Contributor

    Somewhat related to #28632

  2. added
    tree-widget
    bug
    important
    on Nov 29, 2017
  3. weinand commented on Nov 29, 2017

    @weinand
    Contributor

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

  4. added
    tree-views
    and removed
    tree-widget
    on Nov 29, 2017
  5. sandy081 commented on Dec 1, 2017

    @sandy081
    Member

    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?

  6. weinand commented on Dec 1, 2017

    @weinand
    Contributor

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

  7. added
    feature-request
    and removed
    bug
    important
    on Dec 1, 2017
  8. patrys commented on Dec 1, 2017

    @patrys
    Author

    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.

  9. 26 remaining items

  10. zigmondy commented on Jun 6, 2018

    @zigmondy

    Hopefully the capability to suppress collapse on click is built some day. VS code tree view extension feels so limited because of this issue :( !!!

  11. sandy081 commented on Jun 19, 2018

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

    Eric Amodio (@eamodio) I suppose your requirement mentioned here is supported now using the existing APIs

  12. sandy081 commented on Jun 19, 2018

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

  13. eamodio commented on Jun 20, 2018

    @eamodio
    Contributor

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

  14. sandy081 commented on Jun 20, 2018

    @sandy081
    Member

    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.

    • 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.
  15. eamodio commented on Jun 20, 2018

    @eamodio
    Contributor

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

  16. DanTup commented on Jun 20, 2018

    @DanTup
    Contributor

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

  17. TomasHubelbauer commented on Jul 9, 2018

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

  18. sandy081 commented on Jul 10, 2018

    @sandy081
    Member

    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?

  19. zigmondy commented on Jul 10, 2018

    @zigmondy

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

  20. locked and limited conversation to collaborators on Aug 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requesttree-viewsverification-neededverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions