0

I am trying to change the name of the subtab in the console app but it is getting stuck with the tab tille as "Loading...." written this below code to get the issue but not working, can some one help me out for this ...

below is my code : CMP

<aura:component implements="flexipage:availableForAllPageTypes,lightning:isUrlAddressable" access="global">
    <lightning:workspaceAPI aura:id="workspace" />
    <aura:handler name="init" value="{!this}" action="{!c.init}"/> 
    <div class="slds-card">
        <c:testLWC />
    </div>
</aura:component>

Controller:

init: function(cmp, evt, helper) {
        var workspaceAPI = cmp.find("workspace");
        workspaceAPI.getFocusedTabInfo().then(function(response) {
            var focusedTabId = response.tabId;
            workspaceAPI.setTabLabel({
                tabId: focusedTabId,
                label: "Focused Tab"
            });
        })
        .catch(function(error) {
            console.log(error);
        });
    }

enter image description here

0

There is a known issue with using getFocusedTabInfo in the init handler in a controller. Due to race condition getFocusedTabInfo sometimes gives wrong tab information. For your requirement, you should use getEnclosingTabId to get the tab id and then set the tab label

init: function(cmp, evt, helper) {
    var workspaceAPI = cmp.find("workspace");
    workspaceAPI.getEnclosingTabId().then(function(response) {
        workspaceAPI.setTabLabel({
            tabId: response,
            label: "Focused Tab"
        });
    })
    .catch(function(error) {
        console.log(error);
    });
}

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.