-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy path@window-splitter__state@1.1.3.patch
More file actions
114 lines (114 loc) · 6.67 KB
/
Copy path@window-splitter__state@1.1.3.patch
File metadata and controls
114 lines (114 loc) · 6.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
diff --git a/dist/commonjs/index.js b/dist/commonjs/index.js
index e3bdcf702702392e9a06c981545f659ee7c5970e..d88ae6b2dc5b4cf1970cb693f58a926bd12a8f45 100644
--- a/dist/commonjs/index.js
+++ b/dist/commonjs/index.js
@@ -757,30 +757,14 @@ function updateLayout(context, dragEvent) {
panelAfter.onCollapseChange.current(false);
}
}
- const panelBeforeIsAboutToCollapse = panelBefore.currentValue.value.eq(getUnitPixelValue(context, panelBefore.min));
- // If the panel was expanded and now is at it's min size, collapse it
- if (!dragEvent.disregardCollapseBuffer &&
- panelBefore.collapsible &&
- panelBeforeIsAboutToCollapse) {
- if (panelBefore.onCollapseChange?.current &&
- panelBefore.collapseIsControlled &&
- !dragEvent.controlled &&
- !dragEvent.isVirtual) {
- panelBefore.onCollapseChange.current(true);
- return { dragOvershoot: newDragOvershoot };
- }
- // Make it collapsed
- panelBefore.collapsed = true;
- panelBeforeNewValue = getUnitPixelValue(context, panelBefore.collapsedSize);
- // Add the extra space created to the before panel
- panelAfterNewValue = panelAfter.currentValue.value.add(panelBeforePreviousValue.minus(panelBeforeNewValue));
- if (panelBefore.onCollapseChange?.current &&
- !panelBefore.collapseIsControlled &&
- !dragEvent.controlled &&
- !dragEvent.isVirtual) {
- panelBefore.onCollapseChange.current(true);
- }
- }
+ // Drag-to-collapse is disabled in this fork: every consumer of the
+ // library uses controlled `collapsed` props and triggers collapse
+ // explicitly (close button, ESC, URL change, etc.). The original auto-
+ // collapse-on-drag logic that lived here would notify the parent when a
+ // collapsible panel reached its min during a drag — keeping it for our
+ // (controlled-only) case caused state-machine deadlocks when handlers
+ // were no-ops, so the block is removed entirely. Panels just clamp at
+ // `min` during drag now.
panelBefore.currentValue = { type: "pixel", value: panelBeforeNewValue };
panelAfter.currentValue = { type: "pixel", value: panelAfterNewValue };
const leftoverSpace = new big_js_1.default(getGroupSize(context)).minus(newItems.reduce((acc, b) => acc.add(isPanelData(b) ? b.currentValue.value : b.size.value), new big_js_1.default(0)));
@@ -940,7 +924,12 @@ function setCookie(name, jsonData) {
function getDeltaForEvent(context, event) {
const panel = getPanelWithId(context, event.panelId);
if (event.type === "expandPanel") {
- return new big_js_1.default(panel.sizeBeforeCollapse ?? getUnitPixelValue(context, panel.min)).minus(panel.currentValue.value);
+ // Fall back to `default` before `min` so the first-ever expand of a
+ // panel that started life collapsed lands at its configured default
+ // size rather than getting stuck at `min`.
+ const defaultPx = panel.default ? getUnitPixelValue(context, panel.default) : undefined;
+ const target = panel.sizeBeforeCollapse ?? defaultPx ?? getUnitPixelValue(context, panel.min);
+ return new big_js_1.default(target).minus(panel.currentValue.value);
}
const collapsedSize = getUnitPixelValue(context, panel.collapsedSize);
return panel.currentValue.value.minus(collapsedSize);
diff --git a/dist/esm/index.js b/dist/esm/index.js
index f8fddd70c0f1aaed29f2fb0ca0d8093d8ce66335..d1dae8beb1447afca47b91e796b8279135f50c36 100644
--- a/dist/esm/index.js
+++ b/dist/esm/index.js
@@ -728,30 +728,14 @@ function updateLayout(context, dragEvent) {
panelAfter.onCollapseChange.current(false);
}
}
- const panelBeforeIsAboutToCollapse = panelBefore.currentValue.value.eq(getUnitPixelValue(context, panelBefore.min));
- // If the panel was expanded and now is at it's min size, collapse it
- if (!dragEvent.disregardCollapseBuffer &&
- panelBefore.collapsible &&
- panelBeforeIsAboutToCollapse) {
- if (panelBefore.onCollapseChange?.current &&
- panelBefore.collapseIsControlled &&
- !dragEvent.controlled &&
- !dragEvent.isVirtual) {
- panelBefore.onCollapseChange.current(true);
- return { dragOvershoot: newDragOvershoot };
- }
- // Make it collapsed
- panelBefore.collapsed = true;
- panelBeforeNewValue = getUnitPixelValue(context, panelBefore.collapsedSize);
- // Add the extra space created to the before panel
- panelAfterNewValue = panelAfter.currentValue.value.add(panelBeforePreviousValue.minus(panelBeforeNewValue));
- if (panelBefore.onCollapseChange?.current &&
- !panelBefore.collapseIsControlled &&
- !dragEvent.controlled &&
- !dragEvent.isVirtual) {
- panelBefore.onCollapseChange.current(true);
- }
- }
+ // Drag-to-collapse is disabled in this fork: every consumer of the
+ // library uses controlled `collapsed` props and triggers collapse
+ // explicitly (close button, ESC, URL change, etc.). The original auto-
+ // collapse-on-drag logic that lived here would notify the parent when a
+ // collapsible panel reached its min during a drag — keeping it for our
+ // (controlled-only) case caused state-machine deadlocks when handlers
+ // were no-ops, so the block is removed entirely. Panels just clamp at
+ // `min` during drag now.
panelBefore.currentValue = { type: "pixel", value: panelBeforeNewValue };
panelAfter.currentValue = { type: "pixel", value: panelAfterNewValue };
const leftoverSpace = new Big(getGroupSize(context)).minus(newItems.reduce((acc, b) => acc.add(isPanelData(b) ? b.currentValue.value : b.size.value), new Big(0)));
@@ -911,7 +895,12 @@ function setCookie(name, jsonData) {
function getDeltaForEvent(context, event) {
const panel = getPanelWithId(context, event.panelId);
if (event.type === "expandPanel") {
- return new Big(panel.sizeBeforeCollapse ?? getUnitPixelValue(context, panel.min)).minus(panel.currentValue.value);
+ // Fall back to `default` before `min` so the first-ever expand of a
+ // panel that started life collapsed lands at its configured default
+ // size rather than getting stuck at `min`.
+ const defaultPx = panel.default ? getUnitPixelValue(context, panel.default) : undefined;
+ const target = panel.sizeBeforeCollapse ?? defaultPx ?? getUnitPixelValue(context, panel.min);
+ return new Big(target).minus(panel.currentValue.value);
}
const collapsedSize = getUnitPixelValue(context, panel.collapsedSize);
return panel.currentValue.value.minus(collapsedSize);