In Native SF when Tab or Subtab is closed you will beI have implemented force:hasRecordId and I was able to do that by subscribing to lightning:tabClosed
lightning:tabClosed is an application event that indicates a tab has been closed successfully. This event is supported in Lightning console apps only.log the case id can you check the code I used once:
Component:
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,flexipage:availableForAllPageTypes" access="global" >
<lightning:workspaceAPI aura:id="workspace" />
<aura:handler event="lightning:tabClosed" action="{! c.onTabClosed }"/>
Case Id is {!v.recordId}
</aura:component>
Controller:
({
onTabClosed : function(component, event, helper) {
var caseId= component.get("v.recordId")
var tabId = event.getParam('tabId');
console.log("Tab closed: " +tabId);
console.log("Case Id:" + caseId);
}
})