Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

lightning:tabFocused

Indicates a tab was focused.

lightning:tabFocused fires whenever a user selects a workspace tab or subtab, so console navigation users frequently trigger this application event in typical use. This event also fires when going from a tab to a navigation item, or going from a navigation item to a tab. Aura application events notify all listeners registered in the default phase, including listeners in background tabs. Multiple listeners responding at the same time can impact performance. To minimize performance impact, use a utility item as the only listener, or use a custom component event instead.

Response

Name Type Description
previousTabId string The ID of the previously focused tab.
currentTabId string The ID of the currently focused tab.

Example

This example prints a line to the browser’s developer console when a tab is focused, and then returns that tab’s tabInfo object using the getTabInfo() method.

Component code:

1<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
2    <lightning:workspaceAPI aura:id="workspace" />	
3    <aura:handler event="lightning:tabFocused" action="{! c.onTabFocused }"/> 
4</aura:component>

Controller code:

1({
2    onTabFocused : function(component, event, helper) {
3        console.log("Tab Focused");
4        var focusedTabId = event.getParam('currentTabId');
5        var workspaceAPI = component.find("workspace");        
6        workspaceAPI.getTabInfo({
7            tabId : focusedTabId
8        }).then(function(response) {
9            console.log(response);
10        });
11    }
12})