react-resizable-panels 2.1.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/dist/react-resizable-panels.browser.cjs.js +3 -3
- package/dist/react-resizable-panels.browser.development.cjs.js +3 -3
- package/dist/react-resizable-panels.browser.development.esm.js +3 -3
- package/dist/react-resizable-panels.browser.esm.js +3 -3
- package/dist/react-resizable-panels.cjs.js +3 -3
- package/dist/react-resizable-panels.development.cjs.js +3 -3
- package/dist/react-resizable-panels.development.esm.js +3 -3
- package/dist/react-resizable-panels.development.node.cjs.js +3 -3
- package/dist/react-resizable-panels.development.node.esm.js +3 -3
- package/dist/react-resizable-panels.esm.js +3 -3
- package/dist/react-resizable-panels.node.cjs.js +3 -3
- package/dist/react-resizable-panels.node.esm.js +3 -3
- package/package.json +4 -1
- package/src/PanelGroup.test.tsx +21 -0
- package/src/PanelGroup.ts +1 -1
- package/src/PanelResizeHandle.test.tsx +21 -2
- package/src/PanelResizeHandleRegistry.ts +1 -1
- package/src/utils/validatePanelGroupLayout.ts +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.1.2
|
|
4
|
+
- Suppress invalid layout warning for empty panel groups (#396)
|
|
5
|
+
|
|
6
|
+
## 2.1.1
|
|
7
|
+
|
|
8
|
+
- Fix `onDragging` regression (#391)
|
|
9
|
+
- Fix cursor icon behavior in nested panels (#390)
|
|
10
|
+
|
|
3
11
|
## 2.1.0
|
|
4
12
|
|
|
5
|
-
|
|
13
|
+
- Add opt-in support for setting the [`"nonce"` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce) for the global cursor style (#386)
|
|
6
14
|
- Support disabling global cursor styles (#387)
|
|
7
15
|
|
|
8
16
|
## 2.0.23
|
|
@@ -517,7 +517,7 @@ function handlePointerMove(event) {
|
|
|
517
517
|
|
|
518
518
|
// Edge case (see #340)
|
|
519
519
|
// Detect when the pointer has been released outside an iframe on a different domain
|
|
520
|
-
if (event.buttons === 0) {
|
|
520
|
+
if (isPointerDown && event.buttons === 0) {
|
|
521
521
|
isPointerDown = false;
|
|
522
522
|
updateResizeHandlerStates("up", event);
|
|
523
523
|
}
|
|
@@ -1542,7 +1542,7 @@ function validatePanelGroupLayout({
|
|
|
1542
1542
|
// Validate layout expectations
|
|
1543
1543
|
if (nextLayout.length !== panelConstraints.length) {
|
|
1544
1544
|
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
|
|
1545
|
-
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1545
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
1546
1546
|
for (let index = 0; index < panelConstraints.length; index++) {
|
|
1547
1547
|
const unsafeSize = nextLayout[index];
|
|
1548
1548
|
assert(unsafeSize != null, `No layout data found for index ${index}`);
|
|
@@ -1992,7 +1992,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1992
1992
|
// but updating cursor in this scenario would cause a flicker.
|
|
1993
1993
|
if (prevDeltaRef.current != delta) {
|
|
1994
1994
|
prevDeltaRef.current = delta;
|
|
1995
|
-
if (!layoutChanged) {
|
|
1995
|
+
if (!layoutChanged && delta !== 0) {
|
|
1996
1996
|
// If the pointer has moved too far to resize the panel any further, note this so we can update the cursor.
|
|
1997
1997
|
// This mimics VS Code behavior.
|
|
1998
1998
|
if (isHorizontal) {
|
|
@@ -523,7 +523,7 @@ function handlePointerMove(event) {
|
|
|
523
523
|
|
|
524
524
|
// Edge case (see #340)
|
|
525
525
|
// Detect when the pointer has been released outside an iframe on a different domain
|
|
526
|
-
if (event.buttons === 0) {
|
|
526
|
+
if (isPointerDown && event.buttons === 0) {
|
|
527
527
|
isPointerDown = false;
|
|
528
528
|
updateResizeHandlerStates("up", event);
|
|
529
529
|
}
|
|
@@ -1601,7 +1601,7 @@ function validatePanelGroupLayout({
|
|
|
1601
1601
|
// Validate layout expectations
|
|
1602
1602
|
if (nextLayout.length !== panelConstraints.length) {
|
|
1603
1603
|
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
|
|
1604
|
-
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1604
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
1605
1605
|
// This is not ideal so we should warn about it, but it may be recoverable in some cases
|
|
1606
1606
|
// (especially if the amount is small)
|
|
1607
1607
|
{
|
|
@@ -2098,7 +2098,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2098
2098
|
// but updating cursor in this scenario would cause a flicker.
|
|
2099
2099
|
if (prevDeltaRef.current != delta) {
|
|
2100
2100
|
prevDeltaRef.current = delta;
|
|
2101
|
-
if (!layoutChanged) {
|
|
2101
|
+
if (!layoutChanged && delta !== 0) {
|
|
2102
2102
|
// If the pointer has moved too far to resize the panel any further, note this so we can update the cursor.
|
|
2103
2103
|
// This mimics VS Code behavior.
|
|
2104
2104
|
if (isHorizontal) {
|
|
@@ -499,7 +499,7 @@ function handlePointerMove(event) {
|
|
|
499
499
|
|
|
500
500
|
// Edge case (see #340)
|
|
501
501
|
// Detect when the pointer has been released outside an iframe on a different domain
|
|
502
|
-
if (event.buttons === 0) {
|
|
502
|
+
if (isPointerDown && event.buttons === 0) {
|
|
503
503
|
isPointerDown = false;
|
|
504
504
|
updateResizeHandlerStates("up", event);
|
|
505
505
|
}
|
|
@@ -1577,7 +1577,7 @@ function validatePanelGroupLayout({
|
|
|
1577
1577
|
// Validate layout expectations
|
|
1578
1578
|
if (nextLayout.length !== panelConstraints.length) {
|
|
1579
1579
|
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
|
|
1580
|
-
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1580
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
1581
1581
|
// This is not ideal so we should warn about it, but it may be recoverable in some cases
|
|
1582
1582
|
// (especially if the amount is small)
|
|
1583
1583
|
{
|
|
@@ -2074,7 +2074,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2074
2074
|
// but updating cursor in this scenario would cause a flicker.
|
|
2075
2075
|
if (prevDeltaRef.current != delta) {
|
|
2076
2076
|
prevDeltaRef.current = delta;
|
|
2077
|
-
if (!layoutChanged) {
|
|
2077
|
+
if (!layoutChanged && delta !== 0) {
|
|
2078
2078
|
// If the pointer has moved too far to resize the panel any further, note this so we can update the cursor.
|
|
2079
2079
|
// This mimics VS Code behavior.
|
|
2080
2080
|
if (isHorizontal) {
|
|
@@ -493,7 +493,7 @@ function handlePointerMove(event) {
|
|
|
493
493
|
|
|
494
494
|
// Edge case (see #340)
|
|
495
495
|
// Detect when the pointer has been released outside an iframe on a different domain
|
|
496
|
-
if (event.buttons === 0) {
|
|
496
|
+
if (isPointerDown && event.buttons === 0) {
|
|
497
497
|
isPointerDown = false;
|
|
498
498
|
updateResizeHandlerStates("up", event);
|
|
499
499
|
}
|
|
@@ -1518,7 +1518,7 @@ function validatePanelGroupLayout({
|
|
|
1518
1518
|
// Validate layout expectations
|
|
1519
1519
|
if (nextLayout.length !== panelConstraints.length) {
|
|
1520
1520
|
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
|
|
1521
|
-
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1521
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
1522
1522
|
for (let index = 0; index < panelConstraints.length; index++) {
|
|
1523
1523
|
const unsafeSize = nextLayout[index];
|
|
1524
1524
|
assert(unsafeSize != null, `No layout data found for index ${index}`);
|
|
@@ -1968,7 +1968,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1968
1968
|
// but updating cursor in this scenario would cause a flicker.
|
|
1969
1969
|
if (prevDeltaRef.current != delta) {
|
|
1970
1970
|
prevDeltaRef.current = delta;
|
|
1971
|
-
if (!layoutChanged) {
|
|
1971
|
+
if (!layoutChanged && delta !== 0) {
|
|
1972
1972
|
// If the pointer has moved too far to resize the panel any further, note this so we can update the cursor.
|
|
1973
1973
|
// This mimics VS Code behavior.
|
|
1974
1974
|
if (isHorizontal) {
|
|
@@ -519,7 +519,7 @@ function handlePointerMove(event) {
|
|
|
519
519
|
|
|
520
520
|
// Edge case (see #340)
|
|
521
521
|
// Detect when the pointer has been released outside an iframe on a different domain
|
|
522
|
-
if (event.buttons === 0) {
|
|
522
|
+
if (isPointerDown && event.buttons === 0) {
|
|
523
523
|
isPointerDown = false;
|
|
524
524
|
updateResizeHandlerStates("up", event);
|
|
525
525
|
}
|
|
@@ -1544,7 +1544,7 @@ function validatePanelGroupLayout({
|
|
|
1544
1544
|
// Validate layout expectations
|
|
1545
1545
|
if (nextLayout.length !== panelConstraints.length) {
|
|
1546
1546
|
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
|
|
1547
|
-
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1547
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
1548
1548
|
for (let index = 0; index < panelConstraints.length; index++) {
|
|
1549
1549
|
const unsafeSize = nextLayout[index];
|
|
1550
1550
|
assert(unsafeSize != null, `No layout data found for index ${index}`);
|
|
@@ -1994,7 +1994,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1994
1994
|
// but updating cursor in this scenario would cause a flicker.
|
|
1995
1995
|
if (prevDeltaRef.current != delta) {
|
|
1996
1996
|
prevDeltaRef.current = delta;
|
|
1997
|
-
if (!layoutChanged) {
|
|
1997
|
+
if (!layoutChanged && delta !== 0) {
|
|
1998
1998
|
// If the pointer has moved too far to resize the panel any further, note this so we can update the cursor.
|
|
1999
1999
|
// This mimics VS Code behavior.
|
|
2000
2000
|
if (isHorizontal) {
|
|
@@ -530,7 +530,7 @@ function handlePointerMove(event) {
|
|
|
530
530
|
|
|
531
531
|
// Edge case (see #340)
|
|
532
532
|
// Detect when the pointer has been released outside an iframe on a different domain
|
|
533
|
-
if (event.buttons === 0) {
|
|
533
|
+
if (isPointerDown && event.buttons === 0) {
|
|
534
534
|
isPointerDown = false;
|
|
535
535
|
updateResizeHandlerStates("up", event);
|
|
536
536
|
}
|
|
@@ -1608,7 +1608,7 @@ function validatePanelGroupLayout({
|
|
|
1608
1608
|
// Validate layout expectations
|
|
1609
1609
|
if (nextLayout.length !== panelConstraints.length) {
|
|
1610
1610
|
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
|
|
1611
|
-
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1611
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
1612
1612
|
// This is not ideal so we should warn about it, but it may be recoverable in some cases
|
|
1613
1613
|
// (especially if the amount is small)
|
|
1614
1614
|
{
|
|
@@ -2105,7 +2105,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2105
2105
|
// but updating cursor in this scenario would cause a flicker.
|
|
2106
2106
|
if (prevDeltaRef.current != delta) {
|
|
2107
2107
|
prevDeltaRef.current = delta;
|
|
2108
|
-
if (!layoutChanged) {
|
|
2108
|
+
if (!layoutChanged && delta !== 0) {
|
|
2109
2109
|
// If the pointer has moved too far to resize the panel any further, note this so we can update the cursor.
|
|
2110
2110
|
// This mimics VS Code behavior.
|
|
2111
2111
|
if (isHorizontal) {
|
|
@@ -506,7 +506,7 @@ function handlePointerMove(event) {
|
|
|
506
506
|
|
|
507
507
|
// Edge case (see #340)
|
|
508
508
|
// Detect when the pointer has been released outside an iframe on a different domain
|
|
509
|
-
if (event.buttons === 0) {
|
|
509
|
+
if (isPointerDown && event.buttons === 0) {
|
|
510
510
|
isPointerDown = false;
|
|
511
511
|
updateResizeHandlerStates("up", event);
|
|
512
512
|
}
|
|
@@ -1584,7 +1584,7 @@ function validatePanelGroupLayout({
|
|
|
1584
1584
|
// Validate layout expectations
|
|
1585
1585
|
if (nextLayout.length !== panelConstraints.length) {
|
|
1586
1586
|
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
|
|
1587
|
-
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1587
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
1588
1588
|
// This is not ideal so we should warn about it, but it may be recoverable in some cases
|
|
1589
1589
|
// (especially if the amount is small)
|
|
1590
1590
|
{
|
|
@@ -2081,7 +2081,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2081
2081
|
// but updating cursor in this scenario would cause a flicker.
|
|
2082
2082
|
if (prevDeltaRef.current != delta) {
|
|
2083
2083
|
prevDeltaRef.current = delta;
|
|
2084
|
-
if (!layoutChanged) {
|
|
2084
|
+
if (!layoutChanged && delta !== 0) {
|
|
2085
2085
|
// If the pointer has moved too far to resize the panel any further, note this so we can update the cursor.
|
|
2086
2086
|
// This mimics VS Code behavior.
|
|
2087
2087
|
if (isHorizontal) {
|
|
@@ -492,7 +492,7 @@ function handlePointerMove(event) {
|
|
|
492
492
|
|
|
493
493
|
// Edge case (see #340)
|
|
494
494
|
// Detect when the pointer has been released outside an iframe on a different domain
|
|
495
|
-
if (event.buttons === 0) {
|
|
495
|
+
if (isPointerDown && event.buttons === 0) {
|
|
496
496
|
isPointerDown = false;
|
|
497
497
|
updateResizeHandlerStates("up", event);
|
|
498
498
|
}
|
|
@@ -1440,7 +1440,7 @@ function validatePanelGroupLayout({
|
|
|
1440
1440
|
// Validate layout expectations
|
|
1441
1441
|
if (nextLayout.length !== panelConstraints.length) {
|
|
1442
1442
|
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
|
|
1443
|
-
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1443
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
1444
1444
|
// This is not ideal so we should warn about it, but it may be recoverable in some cases
|
|
1445
1445
|
// (especially if the amount is small)
|
|
1446
1446
|
{
|
|
@@ -1873,7 +1873,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1873
1873
|
// but updating cursor in this scenario would cause a flicker.
|
|
1874
1874
|
if (prevDeltaRef.current != delta) {
|
|
1875
1875
|
prevDeltaRef.current = delta;
|
|
1876
|
-
if (!layoutChanged) {
|
|
1876
|
+
if (!layoutChanged && delta !== 0) {
|
|
1877
1877
|
// If the pointer has moved too far to resize the panel any further, note this so we can update the cursor.
|
|
1878
1878
|
// This mimics VS Code behavior.
|
|
1879
1879
|
if (isHorizontal) {
|
|
@@ -468,7 +468,7 @@ function handlePointerMove(event) {
|
|
|
468
468
|
|
|
469
469
|
// Edge case (see #340)
|
|
470
470
|
// Detect when the pointer has been released outside an iframe on a different domain
|
|
471
|
-
if (event.buttons === 0) {
|
|
471
|
+
if (isPointerDown && event.buttons === 0) {
|
|
472
472
|
isPointerDown = false;
|
|
473
473
|
updateResizeHandlerStates("up", event);
|
|
474
474
|
}
|
|
@@ -1416,7 +1416,7 @@ function validatePanelGroupLayout({
|
|
|
1416
1416
|
// Validate layout expectations
|
|
1417
1417
|
if (nextLayout.length !== panelConstraints.length) {
|
|
1418
1418
|
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
|
|
1419
|
-
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1419
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
1420
1420
|
// This is not ideal so we should warn about it, but it may be recoverable in some cases
|
|
1421
1421
|
// (especially if the amount is small)
|
|
1422
1422
|
{
|
|
@@ -1849,7 +1849,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1849
1849
|
// but updating cursor in this scenario would cause a flicker.
|
|
1850
1850
|
if (prevDeltaRef.current != delta) {
|
|
1851
1851
|
prevDeltaRef.current = delta;
|
|
1852
|
-
if (!layoutChanged) {
|
|
1852
|
+
if (!layoutChanged && delta !== 0) {
|
|
1853
1853
|
// If the pointer has moved too far to resize the panel any further, note this so we can update the cursor.
|
|
1854
1854
|
// This mimics VS Code behavior.
|
|
1855
1855
|
if (isHorizontal) {
|
|
@@ -495,7 +495,7 @@ function handlePointerMove(event) {
|
|
|
495
495
|
|
|
496
496
|
// Edge case (see #340)
|
|
497
497
|
// Detect when the pointer has been released outside an iframe on a different domain
|
|
498
|
-
if (event.buttons === 0) {
|
|
498
|
+
if (isPointerDown && event.buttons === 0) {
|
|
499
499
|
isPointerDown = false;
|
|
500
500
|
updateResizeHandlerStates("up", event);
|
|
501
501
|
}
|
|
@@ -1520,7 +1520,7 @@ function validatePanelGroupLayout({
|
|
|
1520
1520
|
// Validate layout expectations
|
|
1521
1521
|
if (nextLayout.length !== panelConstraints.length) {
|
|
1522
1522
|
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
|
|
1523
|
-
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1523
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
1524
1524
|
for (let index = 0; index < panelConstraints.length; index++) {
|
|
1525
1525
|
const unsafeSize = nextLayout[index];
|
|
1526
1526
|
assert(unsafeSize != null, `No layout data found for index ${index}`);
|
|
@@ -1970,7 +1970,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1970
1970
|
// but updating cursor in this scenario would cause a flicker.
|
|
1971
1971
|
if (prevDeltaRef.current != delta) {
|
|
1972
1972
|
prevDeltaRef.current = delta;
|
|
1973
|
-
if (!layoutChanged) {
|
|
1973
|
+
if (!layoutChanged && delta !== 0) {
|
|
1974
1974
|
// If the pointer has moved too far to resize the panel any further, note this so we can update the cursor.
|
|
1975
1975
|
// This mimics VS Code behavior.
|
|
1976
1976
|
if (isHorizontal) {
|
|
@@ -481,7 +481,7 @@ function handlePointerMove(event) {
|
|
|
481
481
|
|
|
482
482
|
// Edge case (see #340)
|
|
483
483
|
// Detect when the pointer has been released outside an iframe on a different domain
|
|
484
|
-
if (event.buttons === 0) {
|
|
484
|
+
if (isPointerDown && event.buttons === 0) {
|
|
485
485
|
isPointerDown = false;
|
|
486
486
|
updateResizeHandlerStates("up", event);
|
|
487
487
|
}
|
|
@@ -1386,7 +1386,7 @@ function validatePanelGroupLayout({
|
|
|
1386
1386
|
// Validate layout expectations
|
|
1387
1387
|
if (nextLayout.length !== panelConstraints.length) {
|
|
1388
1388
|
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
|
|
1389
|
-
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1389
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
1390
1390
|
for (let index = 0; index < panelConstraints.length; index++) {
|
|
1391
1391
|
const unsafeSize = nextLayout[index];
|
|
1392
1392
|
assert(unsafeSize != null, `No layout data found for index ${index}`);
|
|
@@ -1772,7 +1772,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1772
1772
|
// but updating cursor in this scenario would cause a flicker.
|
|
1773
1773
|
if (prevDeltaRef.current != delta) {
|
|
1774
1774
|
prevDeltaRef.current = delta;
|
|
1775
|
-
if (!layoutChanged) {
|
|
1775
|
+
if (!layoutChanged && delta !== 0) {
|
|
1776
1776
|
// If the pointer has moved too far to resize the panel any further, note this so we can update the cursor.
|
|
1777
1777
|
// This mimics VS Code behavior.
|
|
1778
1778
|
if (isHorizontal) {
|
|
@@ -457,7 +457,7 @@ function handlePointerMove(event) {
|
|
|
457
457
|
|
|
458
458
|
// Edge case (see #340)
|
|
459
459
|
// Detect when the pointer has been released outside an iframe on a different domain
|
|
460
|
-
if (event.buttons === 0) {
|
|
460
|
+
if (isPointerDown && event.buttons === 0) {
|
|
461
461
|
isPointerDown = false;
|
|
462
462
|
updateResizeHandlerStates("up", event);
|
|
463
463
|
}
|
|
@@ -1362,7 +1362,7 @@ function validatePanelGroupLayout({
|
|
|
1362
1362
|
// Validate layout expectations
|
|
1363
1363
|
if (nextLayout.length !== panelConstraints.length) {
|
|
1364
1364
|
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
|
|
1365
|
-
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1365
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
1366
1366
|
for (let index = 0; index < panelConstraints.length; index++) {
|
|
1367
1367
|
const unsafeSize = nextLayout[index];
|
|
1368
1368
|
assert(unsafeSize != null, `No layout data found for index ${index}`);
|
|
@@ -1748,7 +1748,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1748
1748
|
// but updating cursor in this scenario would cause a flicker.
|
|
1749
1749
|
if (prevDeltaRef.current != delta) {
|
|
1750
1750
|
prevDeltaRef.current = delta;
|
|
1751
|
-
if (!layoutChanged) {
|
|
1751
|
+
if (!layoutChanged && delta !== 0) {
|
|
1752
1752
|
// If the pointer has moved too far to resize the panel any further, note this so we can update the cursor.
|
|
1753
1753
|
// This mimics VS Code behavior.
|
|
1754
1754
|
if (isHorizontal) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-resizable-panels",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "React components for resizable panel groups/layouts",
|
|
5
5
|
"author": "Brian Vaughn <brian.david.vaughn@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -61,6 +61,9 @@
|
|
|
61
61
|
},
|
|
62
62
|
"types": "dist/react-resizable-panels.cjs.d.ts",
|
|
63
63
|
"scripts": {
|
|
64
|
+
"clear": "pnpm run clear:builds & pnpm run clear:node_modules",
|
|
65
|
+
"clear:builds": "rm -rf ./packages/*/dist",
|
|
66
|
+
"clear:node_modules": "rm -rf ./node_modules",
|
|
64
67
|
"lint": "eslint \"src/**/*.{ts,tsx}\"",
|
|
65
68
|
"test": "jest --config=jest.config.js",
|
|
66
69
|
"test:watch": "jest --config=jest.config.js --watch",
|
package/src/PanelGroup.test.tsx
CHANGED
|
@@ -418,5 +418,26 @@ describe("PanelGroup", () => {
|
|
|
418
418
|
ref.current?.setLayout([60, 80]);
|
|
419
419
|
});
|
|
420
420
|
});
|
|
421
|
+
|
|
422
|
+
it("should warn about an empty layout", () => {
|
|
423
|
+
act(() => {
|
|
424
|
+
root.render(
|
|
425
|
+
<PanelGroup direction="horizontal" id="group-without-handle">
|
|
426
|
+
<Panel />
|
|
427
|
+
</PanelGroup>
|
|
428
|
+
);
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
// Since the layout is empty, no warning is expected (even though the sizes won't total 100%)
|
|
432
|
+
|
|
433
|
+
act(() => {
|
|
434
|
+
root.render(
|
|
435
|
+
<PanelGroup
|
|
436
|
+
direction="horizontal"
|
|
437
|
+
id="group-without-handle"
|
|
438
|
+
></PanelGroup>
|
|
439
|
+
);
|
|
440
|
+
});
|
|
441
|
+
});
|
|
421
442
|
});
|
|
422
443
|
});
|
package/src/PanelGroup.ts
CHANGED
|
@@ -676,7 +676,7 @@ function PanelGroupWithForwardedRef({
|
|
|
676
676
|
if (prevDeltaRef.current != delta) {
|
|
677
677
|
prevDeltaRef.current = delta;
|
|
678
678
|
|
|
679
|
-
if (!layoutChanged) {
|
|
679
|
+
if (!layoutChanged && delta !== 0) {
|
|
680
680
|
// If the pointer has moved too far to resize the panel any further, note this so we can update the cursor.
|
|
681
681
|
// This mimics VS Code behavior.
|
|
682
682
|
if (isHorizontal) {
|
|
@@ -336,13 +336,32 @@ describe("PanelResizeHandle", () => {
|
|
|
336
336
|
expect(onDraggingLeft).toHaveBeenCalledWith(true);
|
|
337
337
|
|
|
338
338
|
expect(cursorUtils.resetGlobalCursorStyle).not.toHaveBeenCalled();
|
|
339
|
-
expect(cursorUtils.setGlobalCursorStyle).
|
|
339
|
+
expect(cursorUtils.setGlobalCursorStyle).toHaveBeenCalled();
|
|
340
|
+
|
|
341
|
+
onDraggingLeft.mockReset();
|
|
342
|
+
|
|
343
|
+
act(() => {
|
|
344
|
+
dispatchPointerEvent("pointermove", leftElement);
|
|
345
|
+
});
|
|
346
|
+
expect(onDraggingLeft).not.toHaveBeenCalled();
|
|
347
|
+
|
|
348
|
+
act(() => {
|
|
349
|
+
dispatchPointerEvent("pointerup", leftElement);
|
|
350
|
+
});
|
|
351
|
+
expect(onDraggingLeft).toHaveBeenCalledTimes(1);
|
|
352
|
+
expect(onDraggingLeft).toHaveBeenCalledWith(false);
|
|
353
|
+
|
|
354
|
+
onDraggingLeft.mockReset();
|
|
355
|
+
|
|
356
|
+
act(() => {
|
|
357
|
+
dispatchPointerEvent("pointermove", leftElement);
|
|
358
|
+
});
|
|
359
|
+
expect(onDraggingLeft).not.toHaveBeenCalled();
|
|
340
360
|
|
|
341
361
|
act(() => {
|
|
342
362
|
root.unmount();
|
|
343
363
|
});
|
|
344
364
|
|
|
345
365
|
expect(cursorUtils.resetGlobalCursorStyle).toHaveBeenCalled();
|
|
346
|
-
expect(cursorUtils.setGlobalCursorStyle).toHaveBeenCalledTimes(1);
|
|
347
366
|
});
|
|
348
367
|
});
|
|
@@ -109,7 +109,7 @@ function handlePointerMove(event: PointerEvent) {
|
|
|
109
109
|
|
|
110
110
|
// Edge case (see #340)
|
|
111
111
|
// Detect when the pointer has been released outside an iframe on a different domain
|
|
112
|
-
if (event.buttons === 0) {
|
|
112
|
+
if (isPointerDown && event.buttons === 0) {
|
|
113
113
|
isPointerDown = false;
|
|
114
114
|
|
|
115
115
|
updateResizeHandlerStates("up", event);
|
|
@@ -25,7 +25,10 @@ export function validatePanelGroupLayout({
|
|
|
25
25
|
.map((size) => `${size}%`)
|
|
26
26
|
.join(", ")}`
|
|
27
27
|
);
|
|
28
|
-
} else if (
|
|
28
|
+
} else if (
|
|
29
|
+
!fuzzyNumbersEqual(nextLayoutTotalSize, 100) &&
|
|
30
|
+
nextLayout.length > 0
|
|
31
|
+
) {
|
|
29
32
|
// This is not ideal so we should warn about it, but it may be recoverable in some cases
|
|
30
33
|
// (especially if the amount is small)
|
|
31
34
|
if (isDevelopment) {
|