issues with v.body and its components

Two issues going on here:

  • First is described in the tabset documentation:

    This component creates its body during runtime. You won’t be able to reference the component during initialization.

  • The second issue is similar and occurs after init: the components which are contained in non-selected tabs are unavailable. After focusing a tab, its component contents are then available to be "found" in the page.

During init no tab contents will be found by aura:id.

After init the selected tab's components can be found through normal component.find('aura:id') methods.

After selecting a tab, that tab's components can continue to be found by aura:id even after selecting other tabs in the tabset.

In the screenshot below:

  • myComp3's method is available because Tab #3 has been selected and its body rendered.
  • myComp1's method is still available after selecting Tab #3.
  • Tab #2 has not been selected and thus it's component's method is not yet rendered or available to be called and throws an error.

enter image description here


I have struggled with find logic related to lightning:tabset and have come to the conclusion - rightly or wrongly - that the problem is with the mixing of namespaces - lighting and c in your case - resulting in the framework blocking the access. Might be hard-wired in the framework or the result of LockerService. The behaviour seems to be that you can't "cross" a component that is in a another namespace to reach components even when those are in the same namespace as your code.

I've resorted to registering child objects (c:comp2 below) when they are created in an attribute of the root component (c:comp1 below) so as to be able to access the child objects:

c:comp1
  lightning:tabset
    lightning:tab
      c:comp2

but it is pretty ugly and painful to do so I hope I'm wrong.