Skip to main content

Remove active tabs on demand


I wanted to keep selected tabs saved for the user, but reset them on some event. Typical use case is that user open page for specific record, the page has multiple tabs and he switch to not default tab. Here starts the issue. When he switch to a different record, it is better to start on default tab, but if he submits the page, it is better to preserve selected tabs.

I have figured out that it is stored in session storage and I have come up with this solution. When the page is loaded with clear flag, then I also remove all tabs on page, otherwise I don't touch it.

const reset_tabs = function() {
    if ('&clear=')) {
        $('div.t-TabsRegion.js-useLocalStorage').each(function() {
            var region_id   = $(this).attr('id');
            var key         = 'ORA_WWV_apex.apexTabs.' + apex.env.APP_ID + '.' + apex.env.APP_PAGE_ID + '.' + region_id + '.activeTab';
            var value       = sessionStorage.getItem(key);
            console.log('RESET_TABS', region_id, key, value);
            sessionStorage.setItem(key, '');

You can fire this code on page load via DA or in your app script:

$(function() {

You can easily modify this to fire on button click or any event you like. Enjoy.

Update: checkout this awesome article about tags from Pierre and my older article about badges on tabs. Do you know where to find it in JS API documentation? :-)

And here is also link for UI documentation.