I have an aura component for case in service console. For every case tab opened, an instance of the component is created. I need a way to know when a component becomes "visible" or "active" (e.g. the case tab containing the component is opened or in focus). I couldn't find any aura event handler that fits my needs.


1 Answer 1


You can do that using a combination of TabFocused event and getEnclosingTabId method like this:


<lightning:workspaceAPI aura:id="workspace" />
<aura:handler event="lightning:tabFocused" action="{! c.onTabFocused }"/> 


onTabFocused : function(component, event, helper) {
    var focusedTabId = event.getParam('currentTabId');
    var workspaceAPI = component.find("workspace");
    workspaceAPI.getEnclosingTabId().then(function(tabId) {
        if(tabId === focusedTabId){
            // This means you have focused this component
    }).catch(function(error) {

Focused tab event gets triggered on all component instances, but the code inside your if will only execute if the current focused tab id is equal to your enclosed tab id. Which means you are focused on a component which is visble in current tab and not on other tabs.

  • Wow! exactly what i need!. Thanks so much!
    – Jonathan P
    Dec 4, 2020 at 9:54

You must log in to answer this question.

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