Skip to content

Commit 4477437

Browse files
committed
remove unused drag-to-collapse path in resizable patch
1 parent 1e61c27 commit 4477437

2 files changed

Lines changed: 69 additions & 35 deletions

File tree

patches/@window-splitter__state@0.4.1.patch

Lines changed: 66 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/dist/commonjs/index.js b/dist/commonjs/index.js
2-
index acb542b1b71a7e808173d938d16f45a484334f94..0b5fcfbd57ea015ace3cc5f255f39f71dccf9f73 100644
2+
index acb542b1b71a7e808173d938d16f45a484334f94..532ab3e4d9adf98ba4a451e423895a1b982c8ded 100644
33
--- a/dist/commonjs/index.js
44
+++ b/dist/commonjs/index.js
55
@@ -107,6 +107,9 @@ function prepareSnapshot(snapshot) {
@@ -12,27 +12,44 @@ index acb542b1b71a7e808173d938d16f45a484334f94..0b5fcfbd57ea015ace3cc5f255f39f71
1212
}
1313
else {
1414
item.size.value = new big_js_1.default(item.size.value);
15-
@@ -648,15 +651,13 @@ function updateLayout(context, dragEvent) {
15+
@@ -646,28 +649,14 @@ function updateLayout(context, dragEvent) {
16+
panelAfter.onCollapseChange.current(false);
17+
}
1618
}
17-
const panelBeforeIsAboutToCollapse = panelBefore.currentValue.value.eq(getUnitPixelValue(context, panelBefore.min));
18-
// If the panel was expanded and now is at it's min size, collapse it
19-
+ // Skip auto-collapse-on-drag for controlled panels: the parent owns the
20-
+ // `collapsed` prop and an empty/no-op handler would otherwise leave the
21-
+ // state machine wedged with accumulating dragOvershoot.
22-
if (!dragEvent.disregardCollapseBuffer &&
23-
panelBefore.collapsible &&
24-
+ !panelBefore.collapseIsControlled &&
25-
panelBeforeIsAboutToCollapse) {
19+
- const panelBeforeIsAboutToCollapse = panelBefore.currentValue.value.eq(getUnitPixelValue(context, panelBefore.min));
20+
- // If the panel was expanded and now is at it's min size, collapse it
21+
- if (!dragEvent.disregardCollapseBuffer &&
22+
- panelBefore.collapsible &&
23+
- panelBeforeIsAboutToCollapse) {
2624
- if (panelBefore.onCollapseChange?.current &&
2725
- panelBefore.collapseIsControlled &&
2826
- !dragEvent.controlled) {
2927
- panelBefore.onCollapseChange.current(true);
3028
- return { dragOvershoot: newDragOvershoot };
3129
- }
32-
// Make it collapsed
33-
panelBefore.collapsed = true;
34-
panelBeforeNewValue = getUnitPixelValue(context, panelBefore.collapsedSize);
35-
@@ -693,7 +694,10 @@ function commitLayout(context) {
30+
- // Make it collapsed
31+
- panelBefore.collapsed = true;
32+
- panelBeforeNewValue = getUnitPixelValue(context, panelBefore.collapsedSize);
33+
- // Add the extra space created to the before panel
34+
- panelAfterNewValue = panelAfterNewValue.add(panelBeforePreviousValue.minus(panelBeforeNewValue));
35+
- if (panelBefore.onCollapseChange?.current &&
36+
- !panelBefore.collapseIsControlled &&
37+
- !dragEvent.controlled) {
38+
- panelBefore.onCollapseChange.current(true);
39+
- }
40+
- }
41+
+ // Drag-to-collapse is disabled in this fork: every consumer of the
42+
+ // library uses controlled `collapsed` props and triggers collapse
43+
+ // explicitly (close button, ESC, URL change, etc.). The original auto-
44+
+ // collapse-on-drag logic that lived here would notify the parent when a
45+
+ // collapsible panel reached its min during a drag — keeping it for our
46+
+ // (controlled-only) case caused state-machine deadlocks when handlers
47+
+ // were no-ops, so the block is removed entirely. Panels just clamp at
48+
+ // `min` during drag now.
49+
panelBefore.currentValue = { type: "pixel", value: panelBeforeNewValue };
50+
panelAfter.currentValue = { type: "pixel", value: panelAfterNewValue };
51+
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)));
52+
@@ -693,7 +682,10 @@ function commitLayout(context) {
3653
});
3754
const staticWidth = getStaticWidth({ ...context, items: newItems });
3855
newItems.forEach((item, index) => {
@@ -44,7 +61,7 @@ index acb542b1b71a7e808173d938d16f45a484334f94..0b5fcfbd57ea015ace3cc5f255f39f71
4461
return;
4562
}
4663
newItems[index] = {
47-
@@ -821,7 +825,12 @@ function clearLastKnownSize(items) {
64+
@@ -821,7 +813,12 @@ function clearLastKnownSize(items) {
4865
function getDeltaForEvent(context, event) {
4966
const panel = getPanelWithId(context, event.panelId);
5067
if (event.type === "expandPanel") {
@@ -59,7 +76,7 @@ index acb542b1b71a7e808173d938d16f45a484334f94..0b5fcfbd57ea015ace3cc5f255f39f71
5976
const collapsedSize = getUnitPixelValue(context, panel.collapsedSize);
6077
return panel.currentValue.value.minus(collapsedSize);
6178
diff --git a/dist/esm/index.js b/dist/esm/index.js
62-
index 8891ac0141135a3a885bd704d9d443458c7a01bf..cb00de4b543d2974a4afcd8999fa2e3e4e392fe8 100644
79+
index 8891ac0141135a3a885bd704d9d443458c7a01bf..13426f6ef9290af0dcaf3ee1d416fb54f8e42745 100644
6380
--- a/dist/esm/index.js
6481
+++ b/dist/esm/index.js
6582
@@ -81,6 +81,9 @@ export function prepareSnapshot(snapshot) {
@@ -72,27 +89,44 @@ index 8891ac0141135a3a885bd704d9d443458c7a01bf..cb00de4b543d2974a4afcd8999fa2e3e
7289
}
7390
else {
7491
item.size.value = new Big(item.size.value);
75-
@@ -622,15 +625,13 @@ function updateLayout(context, dragEvent) {
92+
@@ -620,28 +623,14 @@ function updateLayout(context, dragEvent) {
93+
panelAfter.onCollapseChange.current(false);
94+
}
7695
}
77-
const panelBeforeIsAboutToCollapse = panelBefore.currentValue.value.eq(getUnitPixelValue(context, panelBefore.min));
78-
// If the panel was expanded and now is at it's min size, collapse it
79-
+ // Skip auto-collapse-on-drag for controlled panels: the parent owns the
80-
+ // `collapsed` prop and an empty/no-op handler would otherwise leave the
81-
+ // state machine wedged with accumulating dragOvershoot.
82-
if (!dragEvent.disregardCollapseBuffer &&
83-
panelBefore.collapsible &&
84-
+ !panelBefore.collapseIsControlled &&
85-
panelBeforeIsAboutToCollapse) {
96+
- const panelBeforeIsAboutToCollapse = panelBefore.currentValue.value.eq(getUnitPixelValue(context, panelBefore.min));
97+
- // If the panel was expanded and now is at it's min size, collapse it
98+
- if (!dragEvent.disregardCollapseBuffer &&
99+
- panelBefore.collapsible &&
100+
- panelBeforeIsAboutToCollapse) {
86101
- if (panelBefore.onCollapseChange?.current &&
87102
- panelBefore.collapseIsControlled &&
88103
- !dragEvent.controlled) {
89104
- panelBefore.onCollapseChange.current(true);
90105
- return { dragOvershoot: newDragOvershoot };
91106
- }
92-
// Make it collapsed
93-
panelBefore.collapsed = true;
94-
panelBeforeNewValue = getUnitPixelValue(context, panelBefore.collapsedSize);
95-
@@ -667,7 +668,10 @@ function commitLayout(context) {
107+
- // Make it collapsed
108+
- panelBefore.collapsed = true;
109+
- panelBeforeNewValue = getUnitPixelValue(context, panelBefore.collapsedSize);
110+
- // Add the extra space created to the before panel
111+
- panelAfterNewValue = panelAfterNewValue.add(panelBeforePreviousValue.minus(panelBeforeNewValue));
112+
- if (panelBefore.onCollapseChange?.current &&
113+
- !panelBefore.collapseIsControlled &&
114+
- !dragEvent.controlled) {
115+
- panelBefore.onCollapseChange.current(true);
116+
- }
117+
- }
118+
+ // Drag-to-collapse is disabled in this fork: every consumer of the
119+
+ // library uses controlled `collapsed` props and triggers collapse
120+
+ // explicitly (close button, ESC, URL change, etc.). The original auto-
121+
+ // collapse-on-drag logic that lived here would notify the parent when a
122+
+ // collapsible panel reached its min during a drag — keeping it for our
123+
+ // (controlled-only) case caused state-machine deadlocks when handlers
124+
+ // were no-ops, so the block is removed entirely. Panels just clamp at
125+
+ // `min` during drag now.
126+
panelBefore.currentValue = { type: "pixel", value: panelBeforeNewValue };
127+
panelAfter.currentValue = { type: "pixel", value: panelAfterNewValue };
128+
const leftoverSpace = new Big(getGroupSize(context)).minus(newItems.reduce((acc, b) => acc.add(isPanelData(b) ? b.currentValue.value : b.size.value), new Big(0)));
129+
@@ -667,7 +656,10 @@ function commitLayout(context) {
96130
});
97131
const staticWidth = getStaticWidth({ ...context, items: newItems });
98132
newItems.forEach((item, index) => {
@@ -104,7 +138,7 @@ index 8891ac0141135a3a885bd704d9d443458c7a01bf..cb00de4b543d2974a4afcd8999fa2e3e
104138
return;
105139
}
106140
newItems[index] = {
107-
@@ -795,7 +799,12 @@ function clearLastKnownSize(items) {
141+
@@ -795,7 +787,12 @@ function clearLastKnownSize(items) {
108142
function getDeltaForEvent(context, event) {
109143
const panel = getPanelWithId(context, event.panelId);
110144
if (event.type === "expandPanel") {

pnpm-lock.yaml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)