I have a LWC component on case page with button called Search
, which does a callout and calls another LWC through Aura, that is opened as new tab in the same window, like this:
As you can see, within the main tab 00001713
, we can see 2 new tabs: 00001713
and Edit Contact
.
The problems are:
- The first time I click
Search
it changes the aura component's tab name to Edit Contact. But if click the LWC on case page again I see Loading.... - The second time I click
Search
without refreshing, it changes the00001713
tabs's name to Edit Contact. And because it the second time, problem 1 remains.
How can resolve these 2 problems?
LWC embedded on case page:
handleNavigate() {
this[NavigationMixin.Navigate]({
type: "standard__component",
attributes: {
componentName: "c__PracticesResultsContainer"
}
,
state: {
c__practices: JSON.stringify(this.practices),
c__startPage: this.startPage,
c__endPage: this.endPage,
c__totalrecords: this.totalrecords,
c__totalPages: this.totalPages,
c__codeIndicated: this.practiceCodeIndicated,
c__code: this.codeIndicated
}
});
}
Aura:
<aura:component implements="flexipage:availableForAllPageTypes,lightning:isUrlAddressable" access="global">
<aura:attribute name="practices" type="String"/>
<aura:attribute name="codeIndicated" type="String"/>
<aura:attribute name="code" type="String"/>
<aura:attribute name="startPage" type="Integer"/>
<aura:attribute name="endPage" type="Integer"/>
<aura:attribute name="totalrecords" type="Integer"/>
<aura:attribute name="totalPages" type="Integer"/>
<aura:handler name="init" value="{!this}" action="{!c.init}"/>
<lightning:workspaceAPI aura:id="workspace"/>
<div class="slds-card">
<c:practiceResult practicesString="{!v.practices}" practiceCodeIndicated="{!v.codeIndicated}"
startPage="{!v.startPage}" endPage="{!v.endPage}" totalrecords="{!v.totalrecords}" totalpages="{!v.totalPages}"
code="{!v.code}"
/>
</div>
</aura:component>
Aura component controller:
({
init: function(cmp, evt, helper) {
var workspaceAPI = cmp.find("workspace");
workspaceAPI.getFocusedTabInfo().then(function(response) {
var focusedTabId = response.tabId;
console.log('focusedTabId ' + focusedTabId);
workspaceAPI.setTabLabel({
tabId: focusedTabId,
label: "Edit Contact" //set label you want to set
});
});
var myPageRef = cmp.get("v.pageReference");
//var PaginationList = myPageRef.state.c__PaginationList;
var practices = myPageRef.state.c__practices;
var codeIndicated = myPageRef.state.c__codeIndicated;
var startPage = myPageRef.state.c__startPage;
var endPage = myPageRef.state.c__endPage;
var totalrecords = myPageRef.state.c__totalrecords;
var totalPages = myPageRef.state.c__totalPages;
var code = myPageRef.state.c__code;
cmp.set("v.practices", practices);
cmp.set("v.codeIndicated", codeIndicated);
cmp.set("v.startPage", startPage);
cmp.set("v.endPage", endPage);
cmp.set("v.totalrecords", totalrecords);
cmp.set("v.totalPages", totalPages);
cmp.set("v.code", code);
}
})