Newer Version Available

This content describes an older version of this product. View Latest

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})