Listen for tree-view expand/collapase


Is there an listener or a way to watch & run a method on open and close of tree-view folder.


On opening folder /styles/ call a method that then can do something such as get the list of files inside.

I want to use this to keep styles on a certain file because currently when you collapse a folder the elements are removed from the DOM the styles never get re-added when expanded again.

I’m open to any other ways to do this, other than settimeout…



If you can describe the rules to decide which files to style with CSS, then you don’t have to have an event like you’re describing. This is the approach I use with my file-type-icons package.


The rules are the files in which I have added the class to, but the class only gets added if the file is found in the tree-view DOM.

So when they collapse the classes I have set get removed.
I need to add them back on expanding - kind of like how the git status styles get applied.