Close all Tabs in a Lightning Console

CloseAllTabs

There is an idea on the Idea Exchange about looking for a way to close all tabs in a Lightning Console App.  It’s an existing option in Classic that hasn’t yet made its way to Lightning.

Lightning Console: Close all tabs option

I’ve spent way too much time manually closing tabs and wanted a way to make this easier.

I stumbled across a reference to a component that could be used to refresh a tab in a console and saw that it used a reference to lightning:workspaceAPI.  I was able to use this Lightning Console JavaScript API to query the open tabs in a console view and choose which ones I wanted to close.

There is some debate in the comments on the idea exchange about whether or not to leave pinned tabs open when performing a Close All tabs.  I designed my component to take a single parameter to specify if pinned tabs should be closed or left open.

It’s easy to implement on the Utility Bar.

UtilityBarSetup

When selected, it pops up a Close Tabs button and the component takes care of the rest.

UtilityBar

The component consists of three parts:

  1. Markup (closeConsoleTabs.cmp)
  2. JavaScript Controller (closeConsoleTabsController.js)
  3. Design (parameter) File (closeConsoleTabs.design)

You can get the complete source code and installation instructions here:

GitHub

Check it out and take advantage of a great time saver.

11 thoughts on “Close all Tabs in a Lightning Console

  1. Hi, Eric! Thank you for creating this. It’s generally easier for our users to have something that they can quickly click to do this as opposed to remembering keyboard shortcuts. With that said, I did discover an issue with it whenever I close 13 or more main Tabs. Basically, whenever the “More” drop-down appears. Whenever there are 13 or more Tabs and I utilize the Close Console Tabs Utility Item, the screen gets a little dark, the Tabs close, and I’m presented with a “Sorry to interrupt” SF Page Error. It happens every time I use it with 13 or more main Tabs. The keyboard shortcut closes them all out without issue. I’m not sure if there’s anything that can be done with how it’s coded but wanted to make you aware. Feel free to email me with any questions!

    Like

      1. Yeah, I figured there probably wasn’t much that you could do on your end. Thanks for checking! What’s strange is that the “Sorry to interrupt” message disappears after about a second so I can’t even provide feedback to SF on the issue. Out of curiosity, are you able to replicate the issue? It occurs in both my Sandbox (full) and Production orgs so I don’t think it’s isolated but you never know.

        Like

  2. We have this issue when there are tabs under the more and we change the order of those tabs. Seems to be an issue with focus tab.
    [LCE: workspaceManager#processWorkspacePage() – Failed to process request: jobLibrary – Job: processWorkspacePage, Stage: tasks, Job failed. An error occurred while processing. LCE: workspaceManager#activateTab() – Failed to activate workspace: ctab12, Status: false] h.eval()@*****lightning.force.com/components/navex/workspaceManager.js:42:318 eval()@*****lightning.force.com/libraries/one/jobLibrary.objects.js:7:73

    Like

    1. The issue occurs when the focus is not on the last tab. The error message is shown only when you have a pinned tab. A workaround we have is to move the focus on the last tab and then close all the tabs.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s