Newer Version Available
isSubtab() for Lightning Experience
Checks whether a tab is a subtab. This method works only in
Lightning console apps.
Arguments
| Name | Type | Description |
|---|---|---|
| tabId | string | ID of the tab. |
Aura Components Sample Code
This component has a button that checks whether the focused tab is a subtab and opens a modal with the answer.
Component code:
1<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
2 <lightning:workspaceAPI aura:id="workspace" />
3 <lightning:button label="Is the Focused Tab a Subtab?" onclick="{! c.isFocusedTabSubtab }" />
4 </aura:component>Controller code:
1({
2 isFocusedTabSubtab : function(component, event, helper) {
3 var workspaceAPI = component.find("workspace");
4 workspaceAPI.getFocusedTabInfo().then(function(response) {
5 workspaceAPI.isSubtab({
6 tabId: response.tabId
7 }).then(function(response) {
8 if (response) {
9 confirm("This tab is a subtab.");
10 }
11 else {
12 confirm("This tab is not a subtab.");
13 }
14 });
15 })
16 .catch(function(error) {
17 console.log(error);
18 });
19 }
20})Response
This method returns a promise that, upon success, resolves to
true if the tab is a subtab, and false otherwise.