-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Persistent unused panels (always keep alive) #718
Comments
You can render a panel as That state is persisted when calling |
Hi @mathuo , |
@mathuo we have the similar issue. We have the set of panels, some of them are terminals (xtermjs) or iframes to some stuff inside a sandbox (like a web application), and we want to add a 'Reset layout' button so when user messed up with it they can return back to the initial state (we don't allow to remove panels btw). With the current implementation of the dockview all panels are destroyed and then re-created (fromJSON call), so the state of iframes is lost. |
@mathuo any thoughts on this? |
just in case, i've ended up with this copy of export const setDockviewLayout = (dockviewApi: DockviewApi, layout: SerializedDockview) => {
const { width, height } = dockviewApi;
// move all current panels to a float group
const [firstPanel, ...restPanels] = dockviewApi.panels;
dockviewApi.addFloatingGroup(firstPanel);
const floatingGroup = firstPanel.group;
restPanels.forEach(panel => panel.api.moveTo({ group: floatingGroup }));
(dockviewApi['component']['gridview'] as Gridview).deserialize(layout.grid, {
fromJSON: (node: ISerializedLeafNode<GroupPanelViewState>) => {
const { id, views, activeView } = node.data;
if (typeof id !== 'string') {
throw new Error('group id must be of type string');
}
const group = dockviewApi['component'].createGroup({ id });
dockviewApi['component']._onDidAddGroup.fire(group);
let activePanel: IDockviewPanel | undefined;
for (const child of views) {
const panel = dockviewApi.getPanel(child);
if (!panel) {
return;
}
panel.api.moveTo({ group });
if (activeView === panel.id) {
activePanel = panel;
}
}
activePanel?.api.setActive();
if (!group.activePanel && group.panels.length > 0) {
const panel = group.panels[group.panels.length - 1];
panel.api.setActive();
}
return group;
},
});
dockviewApi.layout(width, height, true);
dockviewApi['component']._onDidLayoutFromJSON.fire();
}; |
Let me try a couple of approaches, I think we can integrate such behaviours into the deserialization methods. |
@mathuo really appreciate it |
Is your feature request related to a problem? Please describe.
Hello 👋
I'm working on a project that changes the layout using
dockviewApi.fromJSON
to load different layouts but from a fixed list of panels. So, in one layout I could have only one panel visible and in another, I have 2 columns of 3 and 2 panels side by side.These panels show iframes which is important to be kept alive on changing the layout.
The current state of DockView to my understanding is that using
fromJSON
will cause removing all the extra panels. Is there any way around it?Describe the solution you'd like
I'm not sure what's the best solution here. I saw #397 but it seems it's not available anymore.
Describe alternatives you've considered
I'm trying to see if using portals and mirroring (somehow) could work here. Or maybe move the extra ones to a floating group and hide that.
The text was updated successfully, but these errors were encountered: