diff --git a/packages/node_modules/@node-red/editor-client/src/js/red.js b/packages/node_modules/@node-red/editor-client/src/js/red.js index 36e45e570..2b1c8f2e4 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/red.js +++ b/packages/node_modules/@node-red/editor-client/src/js/red.js @@ -556,8 +556,7 @@ var RED = (function() { $(".red-ui-header-toolbar").show(); - - RED.sidebar.show(":first"); + RED.sidebar.show(":first", true); setTimeout(function() { loader.end(); diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/sidebar.js b/packages/node_modules/@node-red/editor-client/src/js/ui/sidebar.js index 7402870d4..eb10fe043 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/sidebar.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/sidebar.js @@ -19,6 +19,15 @@ RED.sidebar = (function() { var sidebar_tabs; var knownTabs = {}; + // We store the current sidebar tab id in localStorage as 'last-sidebar-tab' + // This is restored when the editor is reloaded. + // We use sidebar_tabs.onchange to update localStorage. However that will + // also get triggered when the first tab gets added to the tabs - typically + // the 'info' tab. So we use the following variable to store the retrieved + // value from localStorage before we start adding the actual tabs + var lastSessionSelectedTab = null; + + function addTab(title,content,closeable,visible) { var options; if (typeof title === "string") { @@ -194,16 +203,16 @@ RED.sidebar = (function() { RED.events.emit("sidebar:resize"); } - function showSidebar(id) { + function showSidebar(id, skipShowSidebar) { if (id === ":first") { - id = RED.settings.get("editor.sidebar.order",["info", "help", "version-control", "debug"])[0] + id = lastSessionSelectedTab || RED.settings.get("editor.sidebar.order",["info", "help", "version-control", "debug"])[0] } if (id) { if (!containsTab(id) && knownTabs[id]) { sidebar_tabs.addTab(knownTabs[id]); } sidebar_tabs.activateTab(id); - if (!RED.menu.isSelected("menu-item-sidebar")) { + if (!skipShowSidebar && !RED.menu.isSelected("menu-item-sidebar")) { RED.menu.setSelected("menu-item-sidebar",true); } } @@ -227,6 +236,7 @@ RED.sidebar = (function() { if (tab.toolbar) { $(tab.toolbar).show(); } + RED.settings.setLocal("last-sidebar-tab", tab.id) }, onremove: function(tab) { $(tab.wrapper).hide(); @@ -255,7 +265,9 @@ RED.sidebar = (function() { } }); RED.popover.tooltip($("#red-ui-sidebar-separator").find(".red-ui-sidebar-control-right"),RED._("keyboard.toggleSidebar"),"core:toggle-sidebar"); - showSidebar(); + + lastSessionSelectedTab = RED.settings.getLocal("last-sidebar-tab") + RED.sidebar.info.init(); RED.sidebar.help.init(); RED.sidebar.config.init();