# 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:

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

Controller code:

```javascript
                
({
    onTabFocused : function(component, event, helper) {
        console.log("Tab Focused");
        var focusedTabId = event.getParam('currentTabId');
        var workspaceAPI = component.find("workspace");        
        workspaceAPI.getTabInfo({
            tabId : focusedTabId
        }).then(function(response) {
            console.log(response);
        });
    }
})

```
