FlexLayout
FlexLayout copied to clipboard
addTabToActiveTabSet should handle the add when active tabset was closed
Hello,
As per title I noticed this during the usage of this api call, basically I implemented in my ui a buttonbar to reopen the component that I previously closed and to do this I am using this the api call addTabToActiveTabSet. The problem raise when the only tab present in the active tabset has been closed, in this case there isn't an active tabset but I think it would be good to add the element to one of the remaining tabset alive, the first or the last or maybe when the active tabset is closed to define as active another one of the tabsets alive.
Below the call, the problem sits in "var tabsetNode = this.model.getActiveTabset();" that returns undefined.
/**
* Adds a new tab to the active tabset (if there is one)
* @param json the json for the new tab node
* @hidden @internal
*/
Layout.prototype.addTabToActiveTabSet = function (json) {
var tabsetNode = this.model.getActiveTabset();
if (tabsetNode !== undefined) {
this.doAction(Actions_1.default.addNode(json, tabsetNode.getId(), DockLocation_1.default.CENTER, -1));
}
};
I ran into this a problem similar to this today.
I start with an empty layout, getActiveTabset() returns undefined and I go ahead and use getRoot() instead for the target node and create a tab. Subsequently, I remove that tab, deleting the tabset, leaving the same state as initially. However, getActiveTabset() does not return undefined, so my code doesn't recognize it has to add the tab to the root node.
I'm not sure if OP tried to achieve the same thing as me, but we're both ultimately struggling with getActiveTabset(), I think.
EDIT: Never mind.. I did not set the active: true flag in any of my tab sets
I am having a somewhat similar issue (or at least related to not having an active tab set)...
If I create an empty layout a tab set is automatically generated and selected:
{
global: {},
borders: [],
layout: {
type: 'row',
weight: 100,
children: [],
},
}
However, if I create a layout which already contains tab sets and tabs, none of them will be active after mounting. So, the user needs to focus one of the tabs before we can programatically add new ones... huh
I ran into this same issue and noticed that it exists in the default layout of the demo for this package.
Steps to reproduce are
- Select either "Three" or "Wikipedia"
- Close both "Three" and "Wikipedia"
- Click "Add Active"
Nothing happens when you click "Add Active" because there is no active panel.