diff --git a/www/datastore/DataStoreList.js b/www/datastore/DataStoreList.js index 12d311a6..284a6340 100644 --- a/www/datastore/DataStoreList.js +++ b/www/datastore/DataStoreList.js @@ -186,8 +186,13 @@ Ext.define('PBS.datastore.DataStores', { applyState: function(state) { let me = this; - if (state.tab !== undefined) { + if (state.tab !== undefined && me.rendered) { me.setActiveTab(state.tab); + } else if (state.tab) { + // if we are not rendered yet, defer setting the activetab + setTimeout(function() { + me.setActiveTab(state.tab); + }, 10); } }, @@ -228,4 +233,13 @@ Ext.define('PBS.datastore.DataStores', { aclPath: '/datastore', }, ], + + initComponent: function() { + let me = this; + // remove invalid activeTab settings + if (me.activeTab && !me.items.some((item) => item.itemId === me.activeTab)) { + delete me.activeTab; + } + me.callParent(); + }, }); diff --git a/www/datastore/Panel.js b/www/datastore/Panel.js index f0d1317c..d767656e 100644 --- a/www/datastore/Panel.js +++ b/www/datastore/Panel.js @@ -17,8 +17,13 @@ Ext.define('PBS.DataStorePanel', { applyState: function(state) { let me = this; - if (state.tab !== undefined) { + if (state.tab !== undefined && me.rendered) { me.setActiveTab(state.tab); + } else if (state.tab) { + // if we are not rendered yet, defer setting the activetab + setTimeout(function() { + me.setActiveTab(state.tab); + }, 10); } }, @@ -101,6 +106,10 @@ Ext.define('PBS.DataStorePanel', { initComponent: function() { let me = this; me.title = `${gettext("Datastore")}: ${me.datastore}`; + // remove invalid activeTab settings + if (me.activeTab && !me.items.some((item) => item.itemId === me.activeTab)) { + delete me.activeTab; + } me.callParent(); }, });