vscode-elements / elements

Web component library for developing Visual Studio Code extensions
https://vscode-elements.github.io
MIT License
156 stars 27 forks source link

Deselect tree #132

Closed qarlosalberto closed 9 months ago

qarlosalberto commented 9 months ago

Is it possible to unselect a tree item?

qarlosalberto commented 9 months ago

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

bendera commented 9 months ago

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 commented 9 months ago

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

qarlosalberto commented 9 months ago

that would be great!!

El dom., 11 feb. 2024 14:48, Adam Bender @.***> escribió:

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

— Reply to this email directly, view it on GitHub https://github.com/vscode-elements/elements/issues/132#issuecomment-1937759762, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNN4R24LU2YH46VKCRS2OLYTDDZTAVCNFSM6AAAAABDDCFDZCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZXG42TSNZWGI . You are receiving this because you authored the thread.Message ID: @.***>

bendera commented 9 months ago

New version has been released.

qarlosalberto commented 9 months ago

thank you very much!