MCPcopy Create free account
hub / github.com/bvaughn/react-resizable-panels / floatTabset

Function floatTabset

lib/workspace/models/floatTabset.ts:18–51  ·  view source on GitHub ↗
(
  model: WorkspaceModel<TabData, TabsetData>,
  tabsetId: string,
  rect: FloatingTabsetRect
)

Source from the content-addressed store, hash-verified

16 * ℹ️ The root tabset (which fills the workspace) and tabsets that are already floating are left unchanged.
17 */
18export function floatTabset<TabData, TabsetData>(
19 model: WorkspaceModel<TabData, TabsetData>,
20 tabsetId: string,
21 rect: FloatingTabsetRect
22): WorkspaceModel<TabData, TabsetData> {
23 const current = findTabset(model, tabsetId);
24 if (!current || isFloatingTabset(model, current)) {
25 return model;
26 }
27
28 const next = copyModel(model);
29 const tabset = findTabset(next, tabsetId);
30 const parent = findParent(next.root, tabsetId);
31 if (!tabset || !parent) {
32 return model;
33 }
34
35 parent.children.splice(parent.children.indexOf(tabset), 1);
36
37 // A collapsed tabset floats expanded (it can be collapsed again; see FloatingTabsetNode)
38 const { collapsed: _c, collapsible: _cs, size: _s, ...rest } = tabset;
39 const floating: FloatingTabsetNode<TabData, TabsetData> = {
40 ...rest,
41 ...rect
42 };
43 next.floating = [...(next.floating ?? []), floating];
44
45 // A maximized tabset is restored first (floating tabsets can't be maximized)
46 if (next.maximizedTabsetId === tabsetId) {
47 delete next.maximizedTabsetId;
48 }
49
50 return normalizeCopiedModel(next);
51}

Callers 2

WorkspaceComponentFunction · 0.90
floating.test.tsFile · 0.90

Calls 5

findTabsetFunction · 0.90
isFloatingTabsetFunction · 0.90
copyModelFunction · 0.90
findParentFunction · 0.90
normalizeCopiedModelFunction · 0.90

Tested by

no test coverage detected