Can't execute few custom commands when focussed on a custom Tree view

Dear forum members,

I had created a custom tree view based on TreeWidget in theia. Based on certain oprations in the custom tree view, commands (in command registry) are supposed to be executed.

But, when the focus is in the custom tree view, few of the custom commands go missing.
i.e., CommandRegistry.executeCommand does not execute the commands.
also, in this scenario, CommandRegistry.getActiveHandler returns undefined and Error(The command cannot be executed` is thrown.

But, when I change the focus to an editor in main area, those commands gets executed fine !

Can anyone kindly help me solve this issue?
Thanks in advance.

Hi all,
I noticed that the command is a WorkspaceRootUriAwareCommandHandler and needs a valid URI to get enabled !

need to figure out how the selection in the custom tree view can provide a valid URI,

It should work out of the box via the SelectionService. Try to set the globalSelection TreeWidget props to true in your custom tree, and you should get this functionality for free.

Please note, somewhere in your code, it should be possible to derive a URI from the tree node. Otherwise, it won’t work.

Thank you very much, @kittaakos. I shall try that.