react-resizable-panels 2.0.20 → 2.0.21

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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.21
4
+
5
+ - Handle pointer event edge case with different origin iframes (#374)
6
+
3
7
  ## 2.0.20
4
8
 
5
9
  - Reset global cursor if an active resize handle is unmounted (#313)
@@ -492,6 +492,13 @@ function handlePointerMove(event) {
492
492
  x,
493
493
  y
494
494
  } = getResizeEventCoordinates(event);
495
+
496
+ // Edge case (see #340)
497
+ // Detect when the pointer has been released outside an iframe on a different domain
498
+ if (event.buttons === 0) {
499
+ isPointerDown = false;
500
+ updateResizeHandlerStates("up", event);
501
+ }
495
502
  if (!isPointerDown) {
496
503
  const {
497
504
  target
@@ -1931,9 +1938,6 @@ function PanelGroupWithForwardedRef({
1931
1938
  } = dragState !== null && dragState !== void 0 ? dragState : {};
1932
1939
  const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
1933
1940
  let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
1934
- if (delta === 0) {
1935
- return;
1936
- }
1937
1941
 
1938
1942
  // Support RTL layouts
1939
1943
  const isHorizontal = direction === "horizontal";
@@ -498,6 +498,13 @@ function handlePointerMove(event) {
498
498
  x,
499
499
  y
500
500
  } = getResizeEventCoordinates(event);
501
+
502
+ // Edge case (see #340)
503
+ // Detect when the pointer has been released outside an iframe on a different domain
504
+ if (event.buttons === 0) {
505
+ isPointerDown = false;
506
+ updateResizeHandlerStates("up", event);
507
+ }
501
508
  if (!isPointerDown) {
502
509
  const {
503
510
  target
@@ -2037,9 +2044,6 @@ function PanelGroupWithForwardedRef({
2037
2044
  } = dragState !== null && dragState !== void 0 ? dragState : {};
2038
2045
  const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
2039
2046
  let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
2040
- if (delta === 0) {
2041
- return;
2042
- }
2043
2047
 
2044
2048
  // Support RTL layouts
2045
2049
  const isHorizontal = direction === "horizontal";
@@ -474,6 +474,13 @@ function handlePointerMove(event) {
474
474
  x,
475
475
  y
476
476
  } = getResizeEventCoordinates(event);
477
+
478
+ // Edge case (see #340)
479
+ // Detect when the pointer has been released outside an iframe on a different domain
480
+ if (event.buttons === 0) {
481
+ isPointerDown = false;
482
+ updateResizeHandlerStates("up", event);
483
+ }
477
484
  if (!isPointerDown) {
478
485
  const {
479
486
  target
@@ -2013,9 +2020,6 @@ function PanelGroupWithForwardedRef({
2013
2020
  } = dragState !== null && dragState !== void 0 ? dragState : {};
2014
2021
  const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
2015
2022
  let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
2016
- if (delta === 0) {
2017
- return;
2018
- }
2019
2023
 
2020
2024
  // Support RTL layouts
2021
2025
  const isHorizontal = direction === "horizontal";
@@ -468,6 +468,13 @@ function handlePointerMove(event) {
468
468
  x,
469
469
  y
470
470
  } = getResizeEventCoordinates(event);
471
+
472
+ // Edge case (see #340)
473
+ // Detect when the pointer has been released outside an iframe on a different domain
474
+ if (event.buttons === 0) {
475
+ isPointerDown = false;
476
+ updateResizeHandlerStates("up", event);
477
+ }
471
478
  if (!isPointerDown) {
472
479
  const {
473
480
  target
@@ -1907,9 +1914,6 @@ function PanelGroupWithForwardedRef({
1907
1914
  } = dragState !== null && dragState !== void 0 ? dragState : {};
1908
1915
  const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
1909
1916
  let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
1910
- if (delta === 0) {
1911
- return;
1912
- }
1913
1917
 
1914
1918
  // Support RTL layouts
1915
1919
  const isHorizontal = direction === "horizontal";
@@ -494,6 +494,13 @@ function handlePointerMove(event) {
494
494
  x,
495
495
  y
496
496
  } = getResizeEventCoordinates(event);
497
+
498
+ // Edge case (see #340)
499
+ // Detect when the pointer has been released outside an iframe on a different domain
500
+ if (event.buttons === 0) {
501
+ isPointerDown = false;
502
+ updateResizeHandlerStates("up", event);
503
+ }
497
504
  if (!isPointerDown) {
498
505
  const {
499
506
  target
@@ -1933,9 +1940,6 @@ function PanelGroupWithForwardedRef({
1933
1940
  } = dragState !== null && dragState !== void 0 ? dragState : {};
1934
1941
  const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
1935
1942
  let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
1936
- if (delta === 0) {
1937
- return;
1938
- }
1939
1943
 
1940
1944
  // Support RTL layouts
1941
1945
  const isHorizontal = direction === "horizontal";
@@ -505,6 +505,13 @@ function handlePointerMove(event) {
505
505
  x,
506
506
  y
507
507
  } = getResizeEventCoordinates(event);
508
+
509
+ // Edge case (see #340)
510
+ // Detect when the pointer has been released outside an iframe on a different domain
511
+ if (event.buttons === 0) {
512
+ isPointerDown = false;
513
+ updateResizeHandlerStates("up", event);
514
+ }
508
515
  if (!isPointerDown) {
509
516
  const {
510
517
  target
@@ -2044,9 +2051,6 @@ function PanelGroupWithForwardedRef({
2044
2051
  } = dragState !== null && dragState !== void 0 ? dragState : {};
2045
2052
  const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
2046
2053
  let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
2047
- if (delta === 0) {
2048
- return;
2049
- }
2050
2054
 
2051
2055
  // Support RTL layouts
2052
2056
  const isHorizontal = direction === "horizontal";
@@ -481,6 +481,13 @@ function handlePointerMove(event) {
481
481
  x,
482
482
  y
483
483
  } = getResizeEventCoordinates(event);
484
+
485
+ // Edge case (see #340)
486
+ // Detect when the pointer has been released outside an iframe on a different domain
487
+ if (event.buttons === 0) {
488
+ isPointerDown = false;
489
+ updateResizeHandlerStates("up", event);
490
+ }
484
491
  if (!isPointerDown) {
485
492
  const {
486
493
  target
@@ -2020,9 +2027,6 @@ function PanelGroupWithForwardedRef({
2020
2027
  } = dragState !== null && dragState !== void 0 ? dragState : {};
2021
2028
  const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
2022
2029
  let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
2023
- if (delta === 0) {
2024
- return;
2025
- }
2026
2030
 
2027
2031
  // Support RTL layouts
2028
2032
  const isHorizontal = direction === "horizontal";
@@ -467,6 +467,13 @@ function handlePointerMove(event) {
467
467
  x,
468
468
  y
469
469
  } = getResizeEventCoordinates(event);
470
+
471
+ // Edge case (see #340)
472
+ // Detect when the pointer has been released outside an iframe on a different domain
473
+ if (event.buttons === 0) {
474
+ isPointerDown = false;
475
+ updateResizeHandlerStates("up", event);
476
+ }
470
477
  if (!isPointerDown) {
471
478
  const {
472
479
  target
@@ -1812,9 +1819,6 @@ function PanelGroupWithForwardedRef({
1812
1819
  } = dragState !== null && dragState !== void 0 ? dragState : {};
1813
1820
  const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
1814
1821
  let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
1815
- if (delta === 0) {
1816
- return;
1817
- }
1818
1822
 
1819
1823
  // Support RTL layouts
1820
1824
  const isHorizontal = direction === "horizontal";
@@ -443,6 +443,13 @@ function handlePointerMove(event) {
443
443
  x,
444
444
  y
445
445
  } = getResizeEventCoordinates(event);
446
+
447
+ // Edge case (see #340)
448
+ // Detect when the pointer has been released outside an iframe on a different domain
449
+ if (event.buttons === 0) {
450
+ isPointerDown = false;
451
+ updateResizeHandlerStates("up", event);
452
+ }
446
453
  if (!isPointerDown) {
447
454
  const {
448
455
  target
@@ -1788,9 +1795,6 @@ function PanelGroupWithForwardedRef({
1788
1795
  } = dragState !== null && dragState !== void 0 ? dragState : {};
1789
1796
  const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
1790
1797
  let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
1791
- if (delta === 0) {
1792
- return;
1793
- }
1794
1798
 
1795
1799
  // Support RTL layouts
1796
1800
  const isHorizontal = direction === "horizontal";
@@ -470,6 +470,13 @@ function handlePointerMove(event) {
470
470
  x,
471
471
  y
472
472
  } = getResizeEventCoordinates(event);
473
+
474
+ // Edge case (see #340)
475
+ // Detect when the pointer has been released outside an iframe on a different domain
476
+ if (event.buttons === 0) {
477
+ isPointerDown = false;
478
+ updateResizeHandlerStates("up", event);
479
+ }
473
480
  if (!isPointerDown) {
474
481
  const {
475
482
  target
@@ -1909,9 +1916,6 @@ function PanelGroupWithForwardedRef({
1909
1916
  } = dragState !== null && dragState !== void 0 ? dragState : {};
1910
1917
  const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
1911
1918
  let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
1912
- if (delta === 0) {
1913
- return;
1914
- }
1915
1919
 
1916
1920
  // Support RTL layouts
1917
1921
  const isHorizontal = direction === "horizontal";
@@ -456,6 +456,13 @@ function handlePointerMove(event) {
456
456
  x,
457
457
  y
458
458
  } = getResizeEventCoordinates(event);
459
+
460
+ // Edge case (see #340)
461
+ // Detect when the pointer has been released outside an iframe on a different domain
462
+ if (event.buttons === 0) {
463
+ isPointerDown = false;
464
+ updateResizeHandlerStates("up", event);
465
+ }
459
466
  if (!isPointerDown) {
460
467
  const {
461
468
  target
@@ -1711,9 +1718,6 @@ function PanelGroupWithForwardedRef({
1711
1718
  } = dragState !== null && dragState !== void 0 ? dragState : {};
1712
1719
  const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
1713
1720
  let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
1714
- if (delta === 0) {
1715
- return;
1716
- }
1717
1721
 
1718
1722
  // Support RTL layouts
1719
1723
  const isHorizontal = direction === "horizontal";
@@ -432,6 +432,13 @@ function handlePointerMove(event) {
432
432
  x,
433
433
  y
434
434
  } = getResizeEventCoordinates(event);
435
+
436
+ // Edge case (see #340)
437
+ // Detect when the pointer has been released outside an iframe on a different domain
438
+ if (event.buttons === 0) {
439
+ isPointerDown = false;
440
+ updateResizeHandlerStates("up", event);
441
+ }
435
442
  if (!isPointerDown) {
436
443
  const {
437
444
  target
@@ -1687,9 +1694,6 @@ function PanelGroupWithForwardedRef({
1687
1694
  } = dragState !== null && dragState !== void 0 ? dragState : {};
1688
1695
  const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
1689
1696
  let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
1690
- if (delta === 0) {
1691
- return;
1692
- }
1693
1697
 
1694
1698
  // Support RTL layouts
1695
1699
  const isHorizontal = direction === "horizontal";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-resizable-panels",
3
- "version": "2.0.20",
3
+ "version": "2.0.21",
4
4
  "description": "React components for resizable panel groups/layouts",
5
5
  "author": "Brian Vaughn <brian.david.vaughn@gmail.com>",
6
6
  "license": "MIT",
package/src/PanelGroup.ts CHANGED
@@ -638,9 +638,6 @@ function PanelGroupWithForwardedRef({
638
638
  keyboardResizeBy,
639
639
  panelGroupElement
640
640
  );
641
- if (delta === 0) {
642
- return;
643
- }
644
641
 
645
642
  // Support RTL layouts
646
643
  const isHorizontal = direction === "horizontal";
@@ -87,7 +87,7 @@ export function registerResizeHandle(
87
87
  };
88
88
  }
89
89
 
90
- function handlePointerDown(event: ResizeEvent) {
90
+ function handlePointerDown(event: PointerEvent) {
91
91
  const { target } = event;
92
92
  const { x, y } = getResizeEventCoordinates(event);
93
93
 
@@ -104,9 +104,17 @@ function handlePointerDown(event: ResizeEvent) {
104
104
  }
105
105
  }
106
106
 
107
- function handlePointerMove(event: ResizeEvent) {
107
+ function handlePointerMove(event: PointerEvent) {
108
108
  const { x, y } = getResizeEventCoordinates(event);
109
109
 
110
+ // Edge case (see #340)
111
+ // Detect when the pointer has been released outside an iframe on a different domain
112
+ if (event.buttons === 0) {
113
+ isPointerDown = false;
114
+
115
+ updateResizeHandlerStates("up", event);
116
+ }
117
+
110
118
  if (!isPointerDown) {
111
119
  const { target } = event;
112
120
 
@@ -12,6 +12,7 @@ export function dispatchPointerEvent(type: string, target: HTMLElement) {
12
12
  bubbles: true,
13
13
  clientX,
14
14
  clientY,
15
+ buttons: 1,
15
16
  });
16
17
  Object.defineProperties(event, {
17
18
  pageX: {