I am getting my tab as shown in screenshot below which is a component that gets displayed on clicking a quick action button . currently it is showing asterisk how can i show name on tab.
-
please add the minimal required code to reproduce the error?– sanket kumarApr 21, 2020 at 7:05
1 Answer
Use lightning workspace API to rename the tab label for the detailed document you can see the component library.
Here you go the code snippet for same
Test.Cmp
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global">
<!--Attributes-->
<aura:attribute name="accFields" type="Account"/>
<!--Component Start-->
<!--Lightning Workspace API-->
<lightning:workspaceAPI aura:id="workspace"/>
<!--Lightning Force Data to get Account record-->
<force:recordData aura:id="accRecordData"
layoutType="FULL"
recordId="{!v.recordId}"
targetFields="{!v.accFields}"
recordUpdated="{!c.handleRecordUpdate}"/>
<!--Component End-->
Controller.JS
({
handleRecordUpdate: function(component, event, helper) {
var accountFields = component.get("v.accFields");
var workspaceAPI = component.find("workspace");
workspaceAPI.getFocusedTabInfo().then(function(response) {
var focusedTabId = response.tabId;
workspaceAPI.setTabLabel({
tabId: focusedTabId,
label: accountFields.Type + ' - ' + accountFields.Name
});
})
}
})
You can call this method when you need to rename tab. Hope this will help you :)
-
i tried what you suggested but it gives error as : Uncaught (in promise) Error: Could not locate focused tab..– AbhaApr 21, 2020 at 12:03
-
-
in init handler I want to rename the tab as soon as it starts loading , I want instead of loading icon as shown in picture my tab should be renamed.– AbhaApr 22, 2020 at 4:20
-
can you please your code to see the issue as I can find in your code getFocusedTabInfo is returning undefined Apr 22, 2020 at 9:26