1

I have the following:

<lightning:button label="Print" iconName="utility:summary" iconPosition="left" onclick="{!c.printYears}" />
<lightning:tabset >
    <aura:iteration items="{!v.commYears}" var="aYear">
        <lightning:tab label="{!aYear.commYear}" onfocus="{!c.yearSelected}" >

When I press on 'Print' I want to print the currently selected tab but I can't work out which one it is. In the yearSelected(component, event, helper) function I can't work out which tab got the focus nor can I find the label value of the tab. If I could find the label I could store it so that the printYears function would then know what tab was visible. I know that lightning:tab is beta but I would've thought that at least the onfocus function worked as documented. Therefore I assume I'm doing something wrong. When I debug the onfocus callstack I can see the raw DOM object with the label value but then it gets wrapped in this secure object stuff from LockerService and I can't get to the info anymore. What is the correct way to get from a component or event to the tab element triggering the focus event and thence to the label describing the triggering element? Any guidance appreciated. Thanks, Greg.

3

Locker is doing its job - the issue is with the design/implementation of lightning:tab and the team that owns that component is already aware of this issue (and the more general DOM ownership work they need to do). Locker is designed to be secure by default and the component author has to make a conscious decision to grant you access to their DOM.

The work is being tracked by bug W-3453049 if you want to reference this in any cases etc.

0

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.