Is there way how we can catch an event from "lightning-tree" structure in LWC ? For ex.: I want to know which element was selected/clicked.

The same works in Aura, but I have a problem with LWC:


    <lightning-tree items={treeItems} onselect={handleSelect}>


@api recordId;
@track treeItems;
     @track error;
     }) {
         if (data) {
             this.treeItems = data;
             console.log(JSON.stringify(data, null, '\t'));
         } else {
             this.error = error;

    var myName = evt.getParam('name');

I checked the documentation of this structure and onselect attribute is marked as aura action:

onselect Aura Action The action triggered when a tree item is selected.

1 Answer 1


In LWC, you use the detail property, not the event.getParam function (this is for Aura).

    var myName = evt.detail.name;

Make sure you're looking at the Lightning Web Component version of the documentation, and not the Aura Component version.

  • That's correct, just was trying it and it wasn't working in my case, just had 'undefined', probably forgot to refersh the page twice to make new changes work, but now tried again and it works as expected :) Apr 20, 2020 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.