Newer Version Available
lightning:tabFocused
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})