0

I am calling a lightning aura component from a LWC component .

connectedCallback() {
       let recId = this.recordId;
      console.log('recid',this.recordId)
    this[NavigationMixin.Navigate]({
      type: "standard__component",
      attributes: {
        componentName: "c__auraCòmp"
      },
        state: {
            c__recordId: this.recordId
        }
    });
  }
}
``

After this the aura component gets opened in a new Lightning sub tab


Once the lightning component which calls a flow its action is completed I am redirecting  back to the record page from where we called the parent LWc component .
But the subtab remains open as loading .Please let me know how to close the subtab once lightning component is called and flow embeded in it completes .

The Aura component code 

   

     closeModalOnFinish : function(component, event, helper) {
        if(event.getParam('status') === "FINISHED") {
     var navEvt = $A.get("e.force:navigateToSObject");
        navEvt.setParams({
            "recordId": recordId
        });
        navEvt.fire();
            
     var workspaceAPI = component.find("workspace");
            workspaceAPI.getFocusedTabInfo().then(function(response) {
                var focusedTabId = response.tabId;
                 workspaceAPI.disableTabClose({
                             tabId: focusedTabId,
                             disabled: true,
                             closeable:true
                             
                         })
            })}}





1 Answer 1

0

I've encountered this problem before and I think this will help you.

var workspaceAPI = component.find("workspace");
workspaceAPI.getTabInfo().then(function(response) { 
    var closeTabId = response.tabId;
    workspaceAPI.openSubtab({
        parentTabId: response.parentTabId,
        url: URL,
        focus: true
    }).then(function(openedTab) {
        workspaceAPI.setTabLabel({
        tabId: openedTab,
        label: "Label Here"
    });
    workspaceAPI.closeTab({tabId: closeTabId});
    });
})
.catch(function(error) {
    console.log('action error: ', error.message);
});

It is important to state the workspaceAPI.closeTab in .then to make the process synchronized.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .