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

Deselect tree #132

Closed
qarlosalberto opened this issue Feb 10, 2024 · 6 comments
Closed

Deselect tree #132

qarlosalberto opened this issue Feb 10, 2024 · 6 comments

Comments

@qarlosalberto
Copy link

Is it possible to unselect a tree item?

@qarlosalberto
Copy link
Author

My idea is to deselect all when the user click outside the tree.

@bendera
Copy link
Member

bendera commented Feb 11, 2024

Currently, only can be resolved by a workaround. Let's take this example and let's assume the selected item is the "vscode-tree.test.ts":
https://vscode-elements.github.io/components/tree/#custom-icons

const tree = document.querySelector('#custom-icons-example');
tree.data[0].subItems[2].selected = false;
tree.requestUpdate();

You have to find the selected element in the tree data somehow. The payload of the vsc-tree-select event contains the selected menu item data, and every menu item has a path property. In the above example the path is 0/2.

@bendera
Copy link
Member

bendera commented Feb 11, 2024

I found that the Tree component has a private _getItemByPath method. I can expose that and/or add a deselectAll public method.

@qarlosalberto
Copy link
Author

qarlosalberto commented Feb 11, 2024 via email

@bendera
Copy link
Member

bendera commented Feb 11, 2024

New version has been released.

@bendera bendera closed this as completed Feb 11, 2024
@qarlosalberto
Copy link
Author

thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants