react-resizable-panels 2.0.21 → 2.0.22

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.22
4
+
5
+ - Force eager layout re-calculation after panel added/removed (#375)
6
+
3
7
  ## 2.0.21
4
8
 
5
9
  - Handle pointer event edge case with different origin iframes (#374)
@@ -687,6 +687,11 @@ function updateResizeHandlerStates(action, event) {
687
687
  });
688
688
  }
689
689
 
690
+ function useForceUpdate() {
691
+ const [_, setCount] = useState(0);
692
+ return useCallback(() => setCount(prevCount => prevCount + 1), []);
693
+ }
694
+
690
695
  function assert(expectedCondition, message) {
691
696
  if (!expectedCondition) {
692
697
  console.error(message);
@@ -1596,6 +1601,7 @@ function PanelGroupWithForwardedRef({
1596
1601
  const panelGroupElementRef = useRef(null);
1597
1602
  const [dragState, setDragState] = useState(null);
1598
1603
  const [layout, setLayout] = useState([]);
1604
+ const forceUpdate = useForceUpdate();
1599
1605
  const panelIdToLastNotifiedSizeMapRef = useRef({});
1600
1606
  const panelSizeBeforeCollapseRef = useRef(new Map());
1601
1607
  const prevDeltaRef = useRef(0);
@@ -1858,7 +1864,8 @@ function PanelGroupWithForwardedRef({
1858
1864
  }
1859
1865
  });
1860
1866
  eagerValuesRef.current.panelDataArrayChanged = true;
1861
- }, []);
1867
+ forceUpdate();
1868
+ }, [forceUpdate]);
1862
1869
 
1863
1870
  // (Re)calculate group layout whenever panels are registered or unregistered.
1864
1871
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -2090,8 +2097,9 @@ function PanelGroupWithForwardedRef({
2090
2097
  // Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
2091
2098
  delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
2092
2099
  eagerValuesRef.current.panelDataArrayChanged = true;
2100
+ forceUpdate();
2093
2101
  }
2094
- }, []);
2102
+ }, [forceUpdate]);
2095
2103
  const context = useMemo(() => ({
2096
2104
  collapsePanel,
2097
2105
  direction,
@@ -693,6 +693,11 @@ function updateResizeHandlerStates(action, event) {
693
693
  });
694
694
  }
695
695
 
696
+ function useForceUpdate() {
697
+ const [_, setCount] = useState(0);
698
+ return useCallback(() => setCount(prevCount => prevCount + 1), []);
699
+ }
700
+
696
701
  function assert(expectedCondition, message) {
697
702
  if (!expectedCondition) {
698
703
  console.error(message);
@@ -1660,6 +1665,7 @@ function PanelGroupWithForwardedRef({
1660
1665
  const panelGroupElementRef = useRef(null);
1661
1666
  const [dragState, setDragState] = useState(null);
1662
1667
  const [layout, setLayout] = useState([]);
1668
+ const forceUpdate = useForceUpdate();
1663
1669
  const panelIdToLastNotifiedSizeMapRef = useRef({});
1664
1670
  const panelSizeBeforeCollapseRef = useRef(new Map());
1665
1671
  const prevDeltaRef = useRef(0);
@@ -1964,7 +1970,8 @@ function PanelGroupWithForwardedRef({
1964
1970
  }
1965
1971
  });
1966
1972
  eagerValuesRef.current.panelDataArrayChanged = true;
1967
- }, []);
1973
+ forceUpdate();
1974
+ }, [forceUpdate]);
1968
1975
 
1969
1976
  // (Re)calculate group layout whenever panels are registered or unregistered.
1970
1977
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -2196,8 +2203,9 @@ function PanelGroupWithForwardedRef({
2196
2203
  // Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
2197
2204
  delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
2198
2205
  eagerValuesRef.current.panelDataArrayChanged = true;
2206
+ forceUpdate();
2199
2207
  }
2200
- }, []);
2208
+ }, [forceUpdate]);
2201
2209
  const context = useMemo(() => ({
2202
2210
  collapsePanel,
2203
2211
  direction,
@@ -669,6 +669,11 @@ function updateResizeHandlerStates(action, event) {
669
669
  });
670
670
  }
671
671
 
672
+ function useForceUpdate() {
673
+ const [_, setCount] = useState(0);
674
+ return useCallback(() => setCount(prevCount => prevCount + 1), []);
675
+ }
676
+
672
677
  function assert(expectedCondition, message) {
673
678
  if (!expectedCondition) {
674
679
  console.error(message);
@@ -1636,6 +1641,7 @@ function PanelGroupWithForwardedRef({
1636
1641
  const panelGroupElementRef = useRef(null);
1637
1642
  const [dragState, setDragState] = useState(null);
1638
1643
  const [layout, setLayout] = useState([]);
1644
+ const forceUpdate = useForceUpdate();
1639
1645
  const panelIdToLastNotifiedSizeMapRef = useRef({});
1640
1646
  const panelSizeBeforeCollapseRef = useRef(new Map());
1641
1647
  const prevDeltaRef = useRef(0);
@@ -1940,7 +1946,8 @@ function PanelGroupWithForwardedRef({
1940
1946
  }
1941
1947
  });
1942
1948
  eagerValuesRef.current.panelDataArrayChanged = true;
1943
- }, []);
1949
+ forceUpdate();
1950
+ }, [forceUpdate]);
1944
1951
 
1945
1952
  // (Re)calculate group layout whenever panels are registered or unregistered.
1946
1953
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -2172,8 +2179,9 @@ function PanelGroupWithForwardedRef({
2172
2179
  // Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
2173
2180
  delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
2174
2181
  eagerValuesRef.current.panelDataArrayChanged = true;
2182
+ forceUpdate();
2175
2183
  }
2176
- }, []);
2184
+ }, [forceUpdate]);
2177
2185
  const context = useMemo(() => ({
2178
2186
  collapsePanel,
2179
2187
  direction,
@@ -663,6 +663,11 @@ function updateResizeHandlerStates(action, event) {
663
663
  });
664
664
  }
665
665
 
666
+ function useForceUpdate() {
667
+ const [_, setCount] = useState(0);
668
+ return useCallback(() => setCount(prevCount => prevCount + 1), []);
669
+ }
670
+
666
671
  function assert(expectedCondition, message) {
667
672
  if (!expectedCondition) {
668
673
  console.error(message);
@@ -1572,6 +1577,7 @@ function PanelGroupWithForwardedRef({
1572
1577
  const panelGroupElementRef = useRef(null);
1573
1578
  const [dragState, setDragState] = useState(null);
1574
1579
  const [layout, setLayout] = useState([]);
1580
+ const forceUpdate = useForceUpdate();
1575
1581
  const panelIdToLastNotifiedSizeMapRef = useRef({});
1576
1582
  const panelSizeBeforeCollapseRef = useRef(new Map());
1577
1583
  const prevDeltaRef = useRef(0);
@@ -1834,7 +1840,8 @@ function PanelGroupWithForwardedRef({
1834
1840
  }
1835
1841
  });
1836
1842
  eagerValuesRef.current.panelDataArrayChanged = true;
1837
- }, []);
1843
+ forceUpdate();
1844
+ }, [forceUpdate]);
1838
1845
 
1839
1846
  // (Re)calculate group layout whenever panels are registered or unregistered.
1840
1847
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -2066,8 +2073,9 @@ function PanelGroupWithForwardedRef({
2066
2073
  // Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
2067
2074
  delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
2068
2075
  eagerValuesRef.current.panelDataArrayChanged = true;
2076
+ forceUpdate();
2069
2077
  }
2070
- }, []);
2078
+ }, [forceUpdate]);
2071
2079
  const context = useMemo(() => ({
2072
2080
  collapsePanel,
2073
2081
  direction,
@@ -689,6 +689,11 @@ function updateResizeHandlerStates(action, event) {
689
689
  });
690
690
  }
691
691
 
692
+ function useForceUpdate() {
693
+ const [_, setCount] = useState(0);
694
+ return useCallback(() => setCount(prevCount => prevCount + 1), []);
695
+ }
696
+
692
697
  function assert(expectedCondition, message) {
693
698
  if (!expectedCondition) {
694
699
  console.error(message);
@@ -1598,6 +1603,7 @@ function PanelGroupWithForwardedRef({
1598
1603
  const panelGroupElementRef = useRef(null);
1599
1604
  const [dragState, setDragState] = useState(null);
1600
1605
  const [layout, setLayout] = useState([]);
1606
+ const forceUpdate = useForceUpdate();
1601
1607
  const panelIdToLastNotifiedSizeMapRef = useRef({});
1602
1608
  const panelSizeBeforeCollapseRef = useRef(new Map());
1603
1609
  const prevDeltaRef = useRef(0);
@@ -1860,7 +1866,8 @@ function PanelGroupWithForwardedRef({
1860
1866
  }
1861
1867
  });
1862
1868
  eagerValuesRef.current.panelDataArrayChanged = true;
1863
- }, []);
1869
+ forceUpdate();
1870
+ }, [forceUpdate]);
1864
1871
 
1865
1872
  // (Re)calculate group layout whenever panels are registered or unregistered.
1866
1873
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -2092,8 +2099,9 @@ function PanelGroupWithForwardedRef({
2092
2099
  // Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
2093
2100
  delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
2094
2101
  eagerValuesRef.current.panelDataArrayChanged = true;
2102
+ forceUpdate();
2095
2103
  }
2096
- }, []);
2104
+ }, [forceUpdate]);
2097
2105
  const context = useMemo(() => ({
2098
2106
  collapsePanel,
2099
2107
  direction,
@@ -700,6 +700,11 @@ function updateResizeHandlerStates(action, event) {
700
700
  });
701
701
  }
702
702
 
703
+ function useForceUpdate() {
704
+ const [_, setCount] = useState(0);
705
+ return useCallback(() => setCount(prevCount => prevCount + 1), []);
706
+ }
707
+
703
708
  function assert(expectedCondition, message) {
704
709
  if (!expectedCondition) {
705
710
  console.error(message);
@@ -1667,6 +1672,7 @@ function PanelGroupWithForwardedRef({
1667
1672
  const panelGroupElementRef = useRef(null);
1668
1673
  const [dragState, setDragState] = useState(null);
1669
1674
  const [layout, setLayout] = useState([]);
1675
+ const forceUpdate = useForceUpdate();
1670
1676
  const panelIdToLastNotifiedSizeMapRef = useRef({});
1671
1677
  const panelSizeBeforeCollapseRef = useRef(new Map());
1672
1678
  const prevDeltaRef = useRef(0);
@@ -1971,7 +1977,8 @@ function PanelGroupWithForwardedRef({
1971
1977
  }
1972
1978
  });
1973
1979
  eagerValuesRef.current.panelDataArrayChanged = true;
1974
- }, []);
1980
+ forceUpdate();
1981
+ }, [forceUpdate]);
1975
1982
 
1976
1983
  // (Re)calculate group layout whenever panels are registered or unregistered.
1977
1984
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -2203,8 +2210,9 @@ function PanelGroupWithForwardedRef({
2203
2210
  // Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
2204
2211
  delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
2205
2212
  eagerValuesRef.current.panelDataArrayChanged = true;
2213
+ forceUpdate();
2206
2214
  }
2207
- }, []);
2215
+ }, [forceUpdate]);
2208
2216
  const context = useMemo(() => ({
2209
2217
  collapsePanel,
2210
2218
  direction,
@@ -676,6 +676,11 @@ function updateResizeHandlerStates(action, event) {
676
676
  });
677
677
  }
678
678
 
679
+ function useForceUpdate() {
680
+ const [_, setCount] = useState(0);
681
+ return useCallback(() => setCount(prevCount => prevCount + 1), []);
682
+ }
683
+
679
684
  function assert(expectedCondition, message) {
680
685
  if (!expectedCondition) {
681
686
  console.error(message);
@@ -1643,6 +1648,7 @@ function PanelGroupWithForwardedRef({
1643
1648
  const panelGroupElementRef = useRef(null);
1644
1649
  const [dragState, setDragState] = useState(null);
1645
1650
  const [layout, setLayout] = useState([]);
1651
+ const forceUpdate = useForceUpdate();
1646
1652
  const panelIdToLastNotifiedSizeMapRef = useRef({});
1647
1653
  const panelSizeBeforeCollapseRef = useRef(new Map());
1648
1654
  const prevDeltaRef = useRef(0);
@@ -1947,7 +1953,8 @@ function PanelGroupWithForwardedRef({
1947
1953
  }
1948
1954
  });
1949
1955
  eagerValuesRef.current.panelDataArrayChanged = true;
1950
- }, []);
1956
+ forceUpdate();
1957
+ }, [forceUpdate]);
1951
1958
 
1952
1959
  // (Re)calculate group layout whenever panels are registered or unregistered.
1953
1960
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -2179,8 +2186,9 @@ function PanelGroupWithForwardedRef({
2179
2186
  // Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
2180
2187
  delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
2181
2188
  eagerValuesRef.current.panelDataArrayChanged = true;
2189
+ forceUpdate();
2182
2190
  }
2183
- }, []);
2191
+ }, [forceUpdate]);
2184
2192
  const context = useMemo(() => ({
2185
2193
  collapsePanel,
2186
2194
  direction,
@@ -662,6 +662,11 @@ function updateResizeHandlerStates(action, event) {
662
662
  });
663
663
  }
664
664
 
665
+ function useForceUpdate() {
666
+ const [_, setCount] = useState(0);
667
+ return useCallback(() => setCount(prevCount => prevCount + 1), []);
668
+ }
669
+
665
670
  function assert(expectedCondition, message) {
666
671
  if (!expectedCondition) {
667
672
  console.error(message);
@@ -1499,6 +1504,7 @@ function PanelGroupWithForwardedRef({
1499
1504
  const panelGroupElementRef = useRef(null);
1500
1505
  const [dragState, setDragState] = useState(null);
1501
1506
  const [layout, setLayout] = useState([]);
1507
+ const forceUpdate = useForceUpdate();
1502
1508
  const panelIdToLastNotifiedSizeMapRef = useRef({});
1503
1509
  const panelSizeBeforeCollapseRef = useRef(new Map());
1504
1510
  const prevDeltaRef = useRef(0);
@@ -1795,7 +1801,8 @@ function PanelGroupWithForwardedRef({
1795
1801
  }
1796
1802
  });
1797
1803
  eagerValuesRef.current.panelDataArrayChanged = true;
1798
- }, []);
1804
+ forceUpdate();
1805
+ }, [forceUpdate]);
1799
1806
  const registerResizeHandle = useCallback(dragHandleId => {
1800
1807
  return function resizeHandler(event) {
1801
1808
  event.preventDefault();
@@ -1971,8 +1978,9 @@ function PanelGroupWithForwardedRef({
1971
1978
  // Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
1972
1979
  delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
1973
1980
  eagerValuesRef.current.panelDataArrayChanged = true;
1981
+ forceUpdate();
1974
1982
  }
1975
- }, []);
1983
+ }, [forceUpdate]);
1976
1984
  const context = useMemo(() => ({
1977
1985
  collapsePanel,
1978
1986
  direction,
@@ -638,6 +638,11 @@ function updateResizeHandlerStates(action, event) {
638
638
  });
639
639
  }
640
640
 
641
+ function useForceUpdate() {
642
+ const [_, setCount] = useState(0);
643
+ return useCallback(() => setCount(prevCount => prevCount + 1), []);
644
+ }
645
+
641
646
  function assert(expectedCondition, message) {
642
647
  if (!expectedCondition) {
643
648
  console.error(message);
@@ -1475,6 +1480,7 @@ function PanelGroupWithForwardedRef({
1475
1480
  const panelGroupElementRef = useRef(null);
1476
1481
  const [dragState, setDragState] = useState(null);
1477
1482
  const [layout, setLayout] = useState([]);
1483
+ const forceUpdate = useForceUpdate();
1478
1484
  const panelIdToLastNotifiedSizeMapRef = useRef({});
1479
1485
  const panelSizeBeforeCollapseRef = useRef(new Map());
1480
1486
  const prevDeltaRef = useRef(0);
@@ -1771,7 +1777,8 @@ function PanelGroupWithForwardedRef({
1771
1777
  }
1772
1778
  });
1773
1779
  eagerValuesRef.current.panelDataArrayChanged = true;
1774
- }, []);
1780
+ forceUpdate();
1781
+ }, [forceUpdate]);
1775
1782
  const registerResizeHandle = useCallback(dragHandleId => {
1776
1783
  return function resizeHandler(event) {
1777
1784
  event.preventDefault();
@@ -1947,8 +1954,9 @@ function PanelGroupWithForwardedRef({
1947
1954
  // Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
1948
1955
  delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
1949
1956
  eagerValuesRef.current.panelDataArrayChanged = true;
1957
+ forceUpdate();
1950
1958
  }
1951
- }, []);
1959
+ }, [forceUpdate]);
1952
1960
  const context = useMemo(() => ({
1953
1961
  collapsePanel,
1954
1962
  direction,
@@ -665,6 +665,11 @@ function updateResizeHandlerStates(action, event) {
665
665
  });
666
666
  }
667
667
 
668
+ function useForceUpdate() {
669
+ const [_, setCount] = useState(0);
670
+ return useCallback(() => setCount(prevCount => prevCount + 1), []);
671
+ }
672
+
668
673
  function assert(expectedCondition, message) {
669
674
  if (!expectedCondition) {
670
675
  console.error(message);
@@ -1574,6 +1579,7 @@ function PanelGroupWithForwardedRef({
1574
1579
  const panelGroupElementRef = useRef(null);
1575
1580
  const [dragState, setDragState] = useState(null);
1576
1581
  const [layout, setLayout] = useState([]);
1582
+ const forceUpdate = useForceUpdate();
1577
1583
  const panelIdToLastNotifiedSizeMapRef = useRef({});
1578
1584
  const panelSizeBeforeCollapseRef = useRef(new Map());
1579
1585
  const prevDeltaRef = useRef(0);
@@ -1836,7 +1842,8 @@ function PanelGroupWithForwardedRef({
1836
1842
  }
1837
1843
  });
1838
1844
  eagerValuesRef.current.panelDataArrayChanged = true;
1839
- }, []);
1845
+ forceUpdate();
1846
+ }, [forceUpdate]);
1840
1847
 
1841
1848
  // (Re)calculate group layout whenever panels are registered or unregistered.
1842
1849
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -2068,8 +2075,9 @@ function PanelGroupWithForwardedRef({
2068
2075
  // Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
2069
2076
  delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
2070
2077
  eagerValuesRef.current.panelDataArrayChanged = true;
2078
+ forceUpdate();
2071
2079
  }
2072
- }, []);
2080
+ }, [forceUpdate]);
2073
2081
  const context = useMemo(() => ({
2074
2082
  collapsePanel,
2075
2083
  direction,
@@ -651,6 +651,11 @@ function updateResizeHandlerStates(action, event) {
651
651
  });
652
652
  }
653
653
 
654
+ function useForceUpdate() {
655
+ const [_, setCount] = useState(0);
656
+ return useCallback(() => setCount(prevCount => prevCount + 1), []);
657
+ }
658
+
654
659
  function assert(expectedCondition, message) {
655
660
  if (!expectedCondition) {
656
661
  console.error(message);
@@ -1440,6 +1445,7 @@ function PanelGroupWithForwardedRef({
1440
1445
  const panelGroupElementRef = useRef(null);
1441
1446
  const [dragState, setDragState] = useState(null);
1442
1447
  const [layout, setLayout] = useState([]);
1448
+ const forceUpdate = useForceUpdate();
1443
1449
  const panelIdToLastNotifiedSizeMapRef = useRef({});
1444
1450
  const panelSizeBeforeCollapseRef = useRef(new Map());
1445
1451
  const prevDeltaRef = useRef(0);
@@ -1694,7 +1700,8 @@ function PanelGroupWithForwardedRef({
1694
1700
  }
1695
1701
  });
1696
1702
  eagerValuesRef.current.panelDataArrayChanged = true;
1697
- }, []);
1703
+ forceUpdate();
1704
+ }, [forceUpdate]);
1698
1705
  const registerResizeHandle = useCallback(dragHandleId => {
1699
1706
  return function resizeHandler(event) {
1700
1707
  event.preventDefault();
@@ -1870,8 +1877,9 @@ function PanelGroupWithForwardedRef({
1870
1877
  // Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
1871
1878
  delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
1872
1879
  eagerValuesRef.current.panelDataArrayChanged = true;
1880
+ forceUpdate();
1873
1881
  }
1874
- }, []);
1882
+ }, [forceUpdate]);
1875
1883
  const context = useMemo(() => ({
1876
1884
  collapsePanel,
1877
1885
  direction,
@@ -627,6 +627,11 @@ function updateResizeHandlerStates(action, event) {
627
627
  });
628
628
  }
629
629
 
630
+ function useForceUpdate() {
631
+ const [_, setCount] = useState(0);
632
+ return useCallback(() => setCount(prevCount => prevCount + 1), []);
633
+ }
634
+
630
635
  function assert(expectedCondition, message) {
631
636
  if (!expectedCondition) {
632
637
  console.error(message);
@@ -1416,6 +1421,7 @@ function PanelGroupWithForwardedRef({
1416
1421
  const panelGroupElementRef = useRef(null);
1417
1422
  const [dragState, setDragState] = useState(null);
1418
1423
  const [layout, setLayout] = useState([]);
1424
+ const forceUpdate = useForceUpdate();
1419
1425
  const panelIdToLastNotifiedSizeMapRef = useRef({});
1420
1426
  const panelSizeBeforeCollapseRef = useRef(new Map());
1421
1427
  const prevDeltaRef = useRef(0);
@@ -1670,7 +1676,8 @@ function PanelGroupWithForwardedRef({
1670
1676
  }
1671
1677
  });
1672
1678
  eagerValuesRef.current.panelDataArrayChanged = true;
1673
- }, []);
1679
+ forceUpdate();
1680
+ }, [forceUpdate]);
1674
1681
  const registerResizeHandle = useCallback(dragHandleId => {
1675
1682
  return function resizeHandler(event) {
1676
1683
  event.preventDefault();
@@ -1846,8 +1853,9 @@ function PanelGroupWithForwardedRef({
1846
1853
  // Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
1847
1854
  delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
1848
1855
  eagerValuesRef.current.panelDataArrayChanged = true;
1856
+ forceUpdate();
1849
1857
  }
1850
- }, []);
1858
+ }, [forceUpdate]);
1851
1859
  const context = useMemo(() => ({
1852
1860
  collapsePanel,
1853
1861
  direction,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-resizable-panels",
3
- "version": "2.0.21",
3
+ "version": "2.0.22",
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
@@ -13,6 +13,7 @@ import {
13
13
  EXCEEDED_VERTICAL_MIN,
14
14
  reportConstraintsViolation,
15
15
  } from "./PanelResizeHandleRegistry";
16
+ import { useForceUpdate } from "./hooks/useForceUpdate";
16
17
  import useIsomorphicLayoutEffect from "./hooks/useIsomorphicEffect";
17
18
  import useUniqueId from "./hooks/useUniqueId";
18
19
  import { useWindowSplitterPanelGroupBehavior } from "./hooks/useWindowSplitterPanelGroupBehavior";
@@ -123,6 +124,7 @@ function PanelGroupWithForwardedRef({
123
124
  const panelGroupElementRef = useRef<HTMLDivElement | null>(null);
124
125
  const [dragState, setDragState] = useState<DragState | null>(null);
125
126
  const [layout, setLayout] = useState<number[]>([]);
127
+ const forceUpdate = useForceUpdate();
126
128
 
127
129
  const panelIdToLastNotifiedSizeMapRef = useRef<Record<string, number>>({});
128
130
  const panelSizeBeforeCollapseRef = useRef<Map<string, number>>(new Map());
@@ -521,26 +523,31 @@ function PanelGroupWithForwardedRef({
521
523
  return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
522
524
  }, []);
523
525
 
524
- const registerPanel = useCallback((panelData: PanelData) => {
525
- const { panelDataArray } = eagerValuesRef.current;
526
+ const registerPanel = useCallback(
527
+ (panelData: PanelData) => {
528
+ const { panelDataArray } = eagerValuesRef.current;
526
529
 
527
- panelDataArray.push(panelData);
528
- panelDataArray.sort((panelA, panelB) => {
529
- const orderA = panelA.order;
530
- const orderB = panelB.order;
531
- if (orderA == null && orderB == null) {
532
- return 0;
533
- } else if (orderA == null) {
534
- return -1;
535
- } else if (orderB == null) {
536
- return 1;
537
- } else {
538
- return orderA - orderB;
539
- }
540
- });
530
+ panelDataArray.push(panelData);
531
+ panelDataArray.sort((panelA, panelB) => {
532
+ const orderA = panelA.order;
533
+ const orderB = panelB.order;
534
+ if (orderA == null && orderB == null) {
535
+ return 0;
536
+ } else if (orderA == null) {
537
+ return -1;
538
+ } else if (orderB == null) {
539
+ return 1;
540
+ } else {
541
+ return orderA - orderB;
542
+ }
543
+ });
541
544
 
542
- eagerValuesRef.current.panelDataArrayChanged = true;
543
- }, []);
545
+ eagerValuesRef.current.panelDataArrayChanged = true;
546
+
547
+ forceUpdate();
548
+ },
549
+ [forceUpdate]
550
+ );
544
551
 
545
552
  // (Re)calculate group layout whenever panels are registered or unregistered.
546
553
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -844,22 +851,27 @@ function PanelGroupWithForwardedRef({
844
851
  setDragState(null);
845
852
  }, []);
846
853
 
847
- const unregisterPanel = useCallback((panelData: PanelData) => {
848
- const { panelDataArray } = eagerValuesRef.current;
854
+ const unregisterPanel = useCallback(
855
+ (panelData: PanelData) => {
856
+ const { panelDataArray } = eagerValuesRef.current;
849
857
 
850
- const index = findPanelDataIndex(panelDataArray, panelData);
851
- if (index >= 0) {
852
- panelDataArray.splice(index, 1);
858
+ const index = findPanelDataIndex(panelDataArray, panelData);
859
+ if (index >= 0) {
860
+ panelDataArray.splice(index, 1);
853
861
 
854
- // TRICKY
855
- // When a panel is removed from the group, we should delete the most recent prev-size entry for it.
856
- // If we don't do this, then a conditionally rendered panel might not call onResize when it's re-mounted.
857
- // Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
858
- delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
862
+ // TRICKY
863
+ // When a panel is removed from the group, we should delete the most recent prev-size entry for it.
864
+ // If we don't do this, then a conditionally rendered panel might not call onResize when it's re-mounted.
865
+ // Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
866
+ delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
859
867
 
860
- eagerValuesRef.current.panelDataArrayChanged = true;
861
- }
862
- }, []);
868
+ eagerValuesRef.current.panelDataArrayChanged = true;
869
+
870
+ forceUpdate();
871
+ }
872
+ },
873
+ [forceUpdate]
874
+ );
863
875
 
864
876
  const context = useMemo(
865
877
  () =>
@@ -0,0 +1,7 @@
1
+ import { useCallback, useState } from "../vendor/react";
2
+
3
+ export function useForceUpdate() {
4
+ const [_, setCount] = useState(0);
5
+
6
+ return useCallback(() => setCount((prevCount) => prevCount + 1), []);
7
+ }