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

[Extension Authoring] TreeDataProvider update doesn't cause update of collapsibleState of TreeItems #54192

Closed
rugpanov opened this issue Jul 12, 2018 · 16 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug tree-views Extension tree view issues
Milestone

Comments

@rugpanov
Copy link

rugpanov commented Jul 12, 2018

  • VSCode Version: 1.25.0
  • OS Version: Win10

Steps to Reproduce:

  1. Create TreeDataProvider
  2. Put a TreeItemCollapsibleState.Collapsed TreeItem there and save a ref to it
  3. Fire TreeDataProvider#onDidChangeTreeData
    Note: as expected now there is a collapsed TreeItem in the TreeDataProvider
  4. Change collapsibleState of the TreeItem to the TreeItemCollapsibleState.Expanded via the stored ref
  5. Fire TreeDataProvider#onDidChangeTreeData

Expected result: There is an expanded TreeItem in the TreeDataProvider
Actual result: There is a collapsed TreeItem in the TreeDataProvider

Note 1: It worked correctly in VSCode 1.24.0 but not in 1.25.0 for me
Note 2: changing collapsibleState in the UI still works.
Note 3: changing collapsibleState from TreeItemCollapsibleState.Expanded/Collapsed to TreeItemCollapsibleState.None works fine.

@vscodebot
Copy link

vscodebot bot commented Jul 12, 2018

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@rugpanov rugpanov changed the title TreeDataProvider update doesn't cause update of collapsibleState of TreeItems [Extension Authoring] TreeDataProvider update doesn't cause update of collapsibleState of TreeItems Jul 12, 2018
@jrieken jrieken assigned sandy081 and unassigned jrieken Jul 13, 2018
@sandy081
Copy link
Member

Duplicate of #30918

@sandy081 sandy081 marked this as a duplicate of #30918 Jul 13, 2018
@sandy081 sandy081 added the *duplicate Issue identified as a duplicate of another issue(s) label Jul 13, 2018
@vscodebot
Copy link

vscodebot bot commented Jul 13, 2018

Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for existing issues here. See also our issue reporting guidelines.

Happy Coding!

@vscodebot vscodebot bot closed this as completed Jul 13, 2018
@rugpanov
Copy link
Author

@sandy081, are you sure this is the same issue?
One I reported is appeared after update from 1.24.0 to 1.25.0
And it has another description

@sandy081
Copy link
Member

@rugpanov There was a similar issue before which is a dup of #30918.

Since you are mentioning it is working in previous release, I will check it.

@sandy081 sandy081 reopened this Jul 13, 2018
@sandy081 sandy081 added tree-views Extension tree view issues and removed *duplicate Issue identified as a duplicate of another issue(s) labels Jul 13, 2018
@sandy081 sandy081 added this to the July 2018 milestone Jul 13, 2018
@sandy081 sandy081 modified the milestones: July 2018, August 2018 Jul 26, 2018
@fabiospampinato
Copy link
Contributor

fabiospampinato commented Aug 6, 2018

I'm also having this problem.

I want to add a collapse/expand button to the navigation bar, but the only ways that I've found for actually collapsing/expanding the tree are:

  1. Clearing it first, then rebuilding it collapsed/expanded
  2. Change the labels by appending a random number of whitespace characters to them

The obvious solution would be just setting TreeItem.collapsibleState to something, which doesn't work.

@sandy081
Copy link
Member

sandy081 commented Aug 29, 2018

This is another issue related to shouldAutoexpand api from the tree which shares the same root cause of #30918.

@joaomoreno FYI

@sandy081
Copy link
Member

If you want a node to be expanded or collapsed programatically, may be the right approach is to have an API to expand or collapse instead of causing a data change?

@sandy081 sandy081 modified the milestones: August 2018, September 2018 Aug 29, 2018
@sandy081 sandy081 added the bug Issue identified by VS Code Team member as probable bug label Aug 29, 2018
@fabiospampinato
Copy link
Contributor

@sandy081 Why not both an API and listening for a mutation of the collapsibleState property? The "problem" with the API is that we would have to keep references to the TreeItems around.

@sandy081
Copy link
Member

CollapsibleState is view state property and not data property. IMO it was wrongly placed and a method in the TreeView is the right place. Also, we do not want to provide same functionality as multiple APIs.

@rugpanov
Copy link
Author

It used to work with collapsibleState property and some extension authors used it. So from this perspective it would be better to return this way. In any case - with separate API or with previous approach, now it doesn't work and for me this is a problem. Please could you provide a possibility to expand/collapse a collapsible tree item in the nearest release.

@sandy081
Copy link
Member

@rugpanov It only works consistently if you give the state for the first time and was not working completely. See #30918

@rugpanov
Copy link
Author

@sandy081 Now I see. So are there any plans about adding such a functionality? It would be really useful for an extension authoring.

@sandy081
Copy link
Member

There are plans to add an API to expand/collapse - #55879

@johnspurlock
Copy link

.collapse was never added on the view, so it's currently impossible to collapse a single item! .reveal({expand:false}) does not work either.

For example, try to implement toggle-expansion-on-select behavior to mimic the built-in explorer. Can track the real state using onDid(Expand|Collapse)Element, but can only set a new state of expanded, using .reveal({expand:true}) - impossible to set collapsed. Any workarounds appreciated. : )

As mentioned earlier in this bug, updating an existing TreeItem's collapsibleState has no effect.

Current stable (1.31) and insiders (1.32).

Thanks!

@sandy081 sandy081 modified the milestones: March 2019, On Deck Mar 27, 2019
@alexr00 alexr00 self-assigned this Oct 7, 2019
@sandy081 sandy081 removed their assignment Jun 10, 2020
@alexr00
Copy link
Member

alexr00 commented Nov 6, 2020

duplicate of #78970

@alexr00 alexr00 closed this as completed Nov 6, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Dec 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug tree-views Extension tree view issues
Projects
None yet
Development

No branches or pull requests

6 participants