react-resizable-panels 0.0.60 → 0.0.61

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.
@@ -724,6 +724,7 @@ function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
724
724
 
725
725
  function useWindowSplitterPanelGroupBehavior({
726
726
  committedValuesRef,
727
+ eagerValuesRef,
727
728
  groupId,
728
729
  layout,
729
730
  panelDataArray,
@@ -776,7 +777,7 @@ function useWindowSplitterPanelGroupBehavior({
776
777
  useEffect(() => {
777
778
  const {
778
779
  panelDataArray
779
- } = committedValuesRef.current;
780
+ } = eagerValuesRef.current;
780
781
  const groupElement = getPanelGroupElement(groupId);
781
782
  assert(groupElement != null, `No group found for id "${groupId}"`);
782
783
  const handles = getResizeHandleElementsForGroup(groupId);
@@ -834,7 +835,7 @@ function useWindowSplitterPanelGroupBehavior({
834
835
  return () => {
835
836
  cleanupFunctions.forEach(cleanupFunction => cleanupFunction());
836
837
  };
837
- }, [committedValuesRef, groupId, layout, panelDataArray, setLayout]);
838
+ }, [committedValuesRef, eagerValuesRef, groupId, layout, panelDataArray, setLayout]);
838
839
  }
839
840
 
840
841
  function areEqual(arrayA, arrayB) {
@@ -1376,11 +1377,13 @@ function PanelGroupWithForwardedRef({
1376
1377
  id: groupId,
1377
1378
  keyboardResizeByPercentage,
1378
1379
  keyboardResizeByPixels,
1379
- layout,
1380
1380
  onLayout,
1381
- panelDataArray: [],
1382
1381
  storage
1383
1382
  });
1383
+ const eagerValuesRef = useRef({
1384
+ layout,
1385
+ panelDataArray: []
1386
+ });
1384
1387
  const devWarningsRef = useRef({
1385
1388
  didLogIdAndOrderWarning: false,
1386
1389
  didLogPanelConstraintsWarning: false,
@@ -1390,9 +1393,11 @@ function PanelGroupWithForwardedRef({
1390
1393
  getId: () => committedValuesRef.current.id,
1391
1394
  getLayout: () => {
1392
1395
  const {
1393
- id: groupId,
1394
- layout
1396
+ id: groupId
1395
1397
  } = committedValuesRef.current;
1398
+ const {
1399
+ layout
1400
+ } = eagerValuesRef.current;
1396
1401
  const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
1397
1402
  return layout.map(sizePercentage => {
1398
1403
  return {
@@ -1404,10 +1409,12 @@ function PanelGroupWithForwardedRef({
1404
1409
  setLayout: mixedSizes => {
1405
1410
  const {
1406
1411
  id: groupId,
1412
+ onLayout
1413
+ } = committedValuesRef.current;
1414
+ const {
1407
1415
  layout: prevLayout,
1408
- onLayout,
1409
1416
  panelDataArray
1410
- } = committedValuesRef.current;
1417
+ } = eagerValuesRef.current;
1411
1418
  const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
1412
1419
  const unsafeLayout = mixedSizes.map(mixedSize => getPercentageSizeFromMixedSizes(mixedSize, groupSizePixels));
1413
1420
  const safeLayout = validatePanelGroupLayout({
@@ -1417,7 +1424,7 @@ function PanelGroupWithForwardedRef({
1417
1424
  });
1418
1425
  if (!areEqual(prevLayout, safeLayout)) {
1419
1426
  setLayout(safeLayout);
1420
- committedValuesRef.current.layout = safeLayout;
1427
+ eagerValuesRef.current.layout = safeLayout;
1421
1428
  if (onLayout) {
1422
1429
  onLayout(safeLayout.map(sizePercentage => ({
1423
1430
  sizePercentage,
@@ -1442,15 +1449,16 @@ function PanelGroupWithForwardedRef({
1442
1449
 
1443
1450
  useWindowSplitterPanelGroupBehavior({
1444
1451
  committedValuesRef,
1452
+ eagerValuesRef,
1445
1453
  groupId,
1446
1454
  layout,
1447
- panelDataArray: committedValuesRef.current.panelDataArray,
1455
+ panelDataArray: eagerValuesRef.current.panelDataArray,
1448
1456
  setLayout
1449
1457
  });
1450
1458
  useEffect(() => {
1451
1459
  const {
1452
1460
  panelDataArray
1453
- } = committedValuesRef.current;
1461
+ } = eagerValuesRef.current;
1454
1462
 
1455
1463
  // If this panel has been configured to persist sizing information, save sizes to local storage.
1456
1464
  if (autoSaveId) {
@@ -1467,8 +1475,9 @@ function PanelGroupWithForwardedRef({
1467
1475
  }, [autoSaveId, layout, storage]);
1468
1476
  useIsomorphicLayoutEffect(() => {
1469
1477
  const {
1478
+ layout: prevLayout,
1470
1479
  panelDataArray
1471
- } = committedValuesRef.current;
1480
+ } = eagerValuesRef.current;
1472
1481
  const constraints = panelDataArray.map(({
1473
1482
  constraints
1474
1483
  }) => constraints);
@@ -1482,7 +1491,6 @@ function PanelGroupWithForwardedRef({
1482
1491
  const resizeObserver = new ResizeObserver(() => {
1483
1492
  const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
1484
1493
  const {
1485
- layout: prevLayout,
1486
1494
  onLayout
1487
1495
  } = committedValuesRef.current;
1488
1496
  const nextLayout = validatePanelGroupLayout({
@@ -1492,7 +1500,7 @@ function PanelGroupWithForwardedRef({
1492
1500
  });
1493
1501
  if (!areEqual(prevLayout, nextLayout)) {
1494
1502
  setLayout(nextLayout);
1495
- committedValuesRef.current.layout = nextLayout;
1503
+ eagerValuesRef.current.layout = nextLayout;
1496
1504
  if (onLayout) {
1497
1505
  onLayout(nextLayout.map(sizePercentage => ({
1498
1506
  sizePercentage,
@@ -1514,7 +1522,7 @@ function PanelGroupWithForwardedRef({
1514
1522
  {
1515
1523
  const {
1516
1524
  panelDataArray
1517
- } = committedValuesRef.current;
1525
+ } = eagerValuesRef.current;
1518
1526
  const {
1519
1527
  didLogIdAndOrderWarning,
1520
1528
  didLogPanelConstraintsWarning,
@@ -1557,11 +1565,13 @@ function PanelGroupWithForwardedRef({
1557
1565
 
1558
1566
  // External APIs are safe to memoize via committed values ref
1559
1567
  const collapsePanel = useCallback(panelData => {
1568
+ const {
1569
+ onLayout
1570
+ } = committedValuesRef.current;
1560
1571
  const {
1561
1572
  layout: prevLayout,
1562
- onLayout,
1563
1573
  panelDataArray
1564
- } = committedValuesRef.current;
1574
+ } = eagerValuesRef.current;
1565
1575
  if (panelData.constraints.collapsible) {
1566
1576
  const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1567
1577
  const {
@@ -1586,7 +1596,7 @@ function PanelGroupWithForwardedRef({
1586
1596
  });
1587
1597
  if (!compareLayouts(prevLayout, nextLayout)) {
1588
1598
  setLayout(nextLayout);
1589
- committedValuesRef.current.layout = nextLayout;
1599
+ eagerValuesRef.current.layout = nextLayout;
1590
1600
  if (onLayout) {
1591
1601
  onLayout(nextLayout.map(sizePercentage => ({
1592
1602
  sizePercentage,
@@ -1601,11 +1611,13 @@ function PanelGroupWithForwardedRef({
1601
1611
 
1602
1612
  // External APIs are safe to memoize via committed values ref
1603
1613
  const expandPanel = useCallback(panelData => {
1614
+ const {
1615
+ onLayout
1616
+ } = committedValuesRef.current;
1604
1617
  const {
1605
1618
  layout: prevLayout,
1606
- onLayout,
1607
1619
  panelDataArray
1608
- } = committedValuesRef.current;
1620
+ } = eagerValuesRef.current;
1609
1621
  if (panelData.constraints.collapsible) {
1610
1622
  const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1611
1623
  const {
@@ -1631,7 +1643,7 @@ function PanelGroupWithForwardedRef({
1631
1643
  });
1632
1644
  if (!compareLayouts(prevLayout, nextLayout)) {
1633
1645
  setLayout(nextLayout);
1634
- committedValuesRef.current.layout = nextLayout;
1646
+ eagerValuesRef.current.layout = nextLayout;
1635
1647
  if (onLayout) {
1636
1648
  onLayout(nextLayout.map(sizePercentage => ({
1637
1649
  sizePercentage,
@@ -1649,7 +1661,7 @@ function PanelGroupWithForwardedRef({
1649
1661
  const {
1650
1662
  layout,
1651
1663
  panelDataArray
1652
- } = committedValuesRef.current;
1664
+ } = eagerValuesRef.current;
1653
1665
  const {
1654
1666
  panelSizePercentage,
1655
1667
  panelSizePixels
@@ -1664,7 +1676,7 @@ function PanelGroupWithForwardedRef({
1664
1676
  const getPanelStyle = useCallback(panelData => {
1665
1677
  const {
1666
1678
  panelDataArray
1667
- } = committedValuesRef.current;
1679
+ } = eagerValuesRef.current;
1668
1680
  const panelIndex = panelDataArray.indexOf(panelData);
1669
1681
  return computePanelFlexBoxStyle({
1670
1682
  dragState,
@@ -1679,7 +1691,7 @@ function PanelGroupWithForwardedRef({
1679
1691
  const {
1680
1692
  layout,
1681
1693
  panelDataArray
1682
- } = committedValuesRef.current;
1694
+ } = eagerValuesRef.current;
1683
1695
  const {
1684
1696
  collapsedSizePercentage,
1685
1697
  collapsible,
@@ -1693,7 +1705,7 @@ function PanelGroupWithForwardedRef({
1693
1705
  const {
1694
1706
  layout,
1695
1707
  panelDataArray
1696
- } = committedValuesRef.current;
1708
+ } = eagerValuesRef.current;
1697
1709
  const {
1698
1710
  collapsedSizePercentage,
1699
1711
  collapsible,
@@ -1705,11 +1717,13 @@ function PanelGroupWithForwardedRef({
1705
1717
  const {
1706
1718
  autoSaveId,
1707
1719
  id: groupId,
1708
- layout: prevLayout,
1709
1720
  onLayout,
1710
- panelDataArray,
1711
1721
  storage
1712
1722
  } = committedValuesRef.current;
1723
+ const {
1724
+ layout: prevLayout,
1725
+ panelDataArray
1726
+ } = eagerValuesRef.current;
1713
1727
  panelDataArray.push(panelData);
1714
1728
  panelDataArray.sort((panelA, panelB) => {
1715
1729
  const orderA = panelA.order;
@@ -1761,9 +1775,13 @@ function PanelGroupWithForwardedRef({
1761
1775
  layout: unsafeLayout,
1762
1776
  panelConstraints: panelDataArray.map(panelData => panelData.constraints)
1763
1777
  });
1778
+
1779
+ // Offscreen mode makes this a bit weird;
1780
+ // Panels unregister when hidden and re-register when shown again,
1781
+ // but the overall layout doesn't change between these two cases.
1782
+ setLayout(nextLayout);
1783
+ eagerValuesRef.current.layout = nextLayout;
1764
1784
  if (!areEqual(prevLayout, nextLayout)) {
1765
- setLayout(nextLayout);
1766
- committedValuesRef.current.layout = nextLayout;
1767
1785
  if (onLayout) {
1768
1786
  onLayout(nextLayout.map(sizePercentage => ({
1769
1787
  sizePercentage,
@@ -1782,10 +1800,12 @@ function PanelGroupWithForwardedRef({
1782
1800
  id: groupId,
1783
1801
  keyboardResizeByPercentage,
1784
1802
  keyboardResizeByPixels,
1785
- onLayout,
1786
- panelDataArray,
1787
- layout: prevLayout
1803
+ onLayout
1788
1804
  } = committedValuesRef.current;
1805
+ const {
1806
+ layout: prevLayout,
1807
+ panelDataArray
1808
+ } = eagerValuesRef.current;
1789
1809
  const {
1790
1810
  initialLayout
1791
1811
  } = dragState !== null && dragState !== void 0 ? dragState : {};
@@ -1841,7 +1861,7 @@ function PanelGroupWithForwardedRef({
1841
1861
  }
1842
1862
  if (layoutChanged) {
1843
1863
  setLayout(nextLayout);
1844
- committedValuesRef.current.layout = nextLayout;
1864
+ eagerValuesRef.current.layout = nextLayout;
1845
1865
  if (onLayout) {
1846
1866
  onLayout(nextLayout.map(sizePercentage => ({
1847
1867
  sizePercentage,
@@ -1855,11 +1875,13 @@ function PanelGroupWithForwardedRef({
1855
1875
 
1856
1876
  // External APIs are safe to memoize via committed values ref
1857
1877
  const resizePanel = useCallback((panelData, mixedSizes) => {
1878
+ const {
1879
+ onLayout
1880
+ } = committedValuesRef.current;
1858
1881
  const {
1859
1882
  layout: prevLayout,
1860
- onLayout,
1861
1883
  panelDataArray
1862
- } = committedValuesRef.current;
1884
+ } = eagerValuesRef.current;
1863
1885
  const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1864
1886
  const {
1865
1887
  groupSizePixels,
@@ -1879,7 +1901,7 @@ function PanelGroupWithForwardedRef({
1879
1901
  });
1880
1902
  if (!compareLayouts(prevLayout, nextLayout)) {
1881
1903
  setLayout(nextLayout);
1882
- committedValuesRef.current.layout = nextLayout;
1904
+ eagerValuesRef.current.layout = nextLayout;
1883
1905
  if (onLayout) {
1884
1906
  onLayout(nextLayout.map(sizePercentage => ({
1885
1907
  sizePercentage,
@@ -1891,9 +1913,11 @@ function PanelGroupWithForwardedRef({
1891
1913
  }, [groupId]);
1892
1914
  const startDragging = useCallback((dragHandleId, event) => {
1893
1915
  const {
1894
- direction,
1895
- layout
1916
+ direction
1896
1917
  } = committedValuesRef.current;
1918
+ const {
1919
+ layout
1920
+ } = eagerValuesRef.current;
1897
1921
  const handleElement = getResizeHandleElement(dragHandleId);
1898
1922
  const initialCursorPosition = getResizeEventCursorPosition(direction, event);
1899
1923
  setDragState({
@@ -1914,10 +1938,12 @@ function PanelGroupWithForwardedRef({
1914
1938
  const unregisterPanel = useCallback(panelData => {
1915
1939
  const {
1916
1940
  id: groupId,
1941
+ onLayout
1942
+ } = committedValuesRef.current;
1943
+ const {
1917
1944
  layout: prevLayout,
1918
- onLayout,
1919
1945
  panelDataArray
1920
- } = committedValuesRef.current;
1946
+ } = eagerValuesRef.current;
1921
1947
  const index = panelDataArray.indexOf(panelData);
1922
1948
  if (index >= 0) {
1923
1949
  panelDataArray.splice(index, 1);
@@ -1934,7 +1960,7 @@ function PanelGroupWithForwardedRef({
1934
1960
  const {
1935
1961
  pendingPanelIds
1936
1962
  } = unregisterPanelRef.current;
1937
- panelIdToLastNotifiedMixedSizesMapRef.current;
1963
+ const map = panelIdToLastNotifiedMixedSizesMapRef.current;
1938
1964
 
1939
1965
  // TRICKY
1940
1966
  // Strict effects mode
@@ -1950,7 +1976,7 @@ function PanelGroupWithForwardedRef({
1950
1976
  // When a panel is removed from the group, we should delete the most recent prev-size entry for it.
1951
1977
  // If we don't do this, then a conditionally rendered panel might not call onResize when it's re-mounted.
1952
1978
  // Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
1953
- delete panelIdToLastNotifiedMixedSizesMapRef.current[panelData.id];
1979
+ delete map[panelData.id];
1954
1980
  }
1955
1981
  });
1956
1982
  if (!unmountDueToStrictMode) {
@@ -1975,7 +2001,7 @@ function PanelGroupWithForwardedRef({
1975
2001
  });
1976
2002
  if (!areEqual(prevLayout, nextLayout)) {
1977
2003
  setLayout(nextLayout);
1978
- committedValuesRef.current.layout = nextLayout;
2004
+ eagerValuesRef.current.layout = nextLayout;
1979
2005
  if (onLayout) {
1980
2006
  onLayout(nextLayout.map(sizePercentage => ({
1981
2007
  sizePercentage,
@@ -700,6 +700,7 @@ function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
700
700
 
701
701
  function useWindowSplitterPanelGroupBehavior({
702
702
  committedValuesRef,
703
+ eagerValuesRef,
703
704
  groupId,
704
705
  layout,
705
706
  panelDataArray,
@@ -752,7 +753,7 @@ function useWindowSplitterPanelGroupBehavior({
752
753
  useEffect(() => {
753
754
  const {
754
755
  panelDataArray
755
- } = committedValuesRef.current;
756
+ } = eagerValuesRef.current;
756
757
  const groupElement = getPanelGroupElement(groupId);
757
758
  assert(groupElement != null, `No group found for id "${groupId}"`);
758
759
  const handles = getResizeHandleElementsForGroup(groupId);
@@ -810,7 +811,7 @@ function useWindowSplitterPanelGroupBehavior({
810
811
  return () => {
811
812
  cleanupFunctions.forEach(cleanupFunction => cleanupFunction());
812
813
  };
813
- }, [committedValuesRef, groupId, layout, panelDataArray, setLayout]);
814
+ }, [committedValuesRef, eagerValuesRef, groupId, layout, panelDataArray, setLayout]);
814
815
  }
815
816
 
816
817
  function areEqual(arrayA, arrayB) {
@@ -1352,11 +1353,13 @@ function PanelGroupWithForwardedRef({
1352
1353
  id: groupId,
1353
1354
  keyboardResizeByPercentage,
1354
1355
  keyboardResizeByPixels,
1355
- layout,
1356
1356
  onLayout,
1357
- panelDataArray: [],
1358
1357
  storage
1359
1358
  });
1359
+ const eagerValuesRef = useRef({
1360
+ layout,
1361
+ panelDataArray: []
1362
+ });
1360
1363
  const devWarningsRef = useRef({
1361
1364
  didLogIdAndOrderWarning: false,
1362
1365
  didLogPanelConstraintsWarning: false,
@@ -1366,9 +1369,11 @@ function PanelGroupWithForwardedRef({
1366
1369
  getId: () => committedValuesRef.current.id,
1367
1370
  getLayout: () => {
1368
1371
  const {
1369
- id: groupId,
1370
- layout
1372
+ id: groupId
1371
1373
  } = committedValuesRef.current;
1374
+ const {
1375
+ layout
1376
+ } = eagerValuesRef.current;
1372
1377
  const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
1373
1378
  return layout.map(sizePercentage => {
1374
1379
  return {
@@ -1380,10 +1385,12 @@ function PanelGroupWithForwardedRef({
1380
1385
  setLayout: mixedSizes => {
1381
1386
  const {
1382
1387
  id: groupId,
1388
+ onLayout
1389
+ } = committedValuesRef.current;
1390
+ const {
1383
1391
  layout: prevLayout,
1384
- onLayout,
1385
1392
  panelDataArray
1386
- } = committedValuesRef.current;
1393
+ } = eagerValuesRef.current;
1387
1394
  const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
1388
1395
  const unsafeLayout = mixedSizes.map(mixedSize => getPercentageSizeFromMixedSizes(mixedSize, groupSizePixels));
1389
1396
  const safeLayout = validatePanelGroupLayout({
@@ -1393,7 +1400,7 @@ function PanelGroupWithForwardedRef({
1393
1400
  });
1394
1401
  if (!areEqual(prevLayout, safeLayout)) {
1395
1402
  setLayout(safeLayout);
1396
- committedValuesRef.current.layout = safeLayout;
1403
+ eagerValuesRef.current.layout = safeLayout;
1397
1404
  if (onLayout) {
1398
1405
  onLayout(safeLayout.map(sizePercentage => ({
1399
1406
  sizePercentage,
@@ -1418,15 +1425,16 @@ function PanelGroupWithForwardedRef({
1418
1425
 
1419
1426
  useWindowSplitterPanelGroupBehavior({
1420
1427
  committedValuesRef,
1428
+ eagerValuesRef,
1421
1429
  groupId,
1422
1430
  layout,
1423
- panelDataArray: committedValuesRef.current.panelDataArray,
1431
+ panelDataArray: eagerValuesRef.current.panelDataArray,
1424
1432
  setLayout
1425
1433
  });
1426
1434
  useEffect(() => {
1427
1435
  const {
1428
1436
  panelDataArray
1429
- } = committedValuesRef.current;
1437
+ } = eagerValuesRef.current;
1430
1438
 
1431
1439
  // If this panel has been configured to persist sizing information, save sizes to local storage.
1432
1440
  if (autoSaveId) {
@@ -1443,8 +1451,9 @@ function PanelGroupWithForwardedRef({
1443
1451
  }, [autoSaveId, layout, storage]);
1444
1452
  useIsomorphicLayoutEffect(() => {
1445
1453
  const {
1454
+ layout: prevLayout,
1446
1455
  panelDataArray
1447
- } = committedValuesRef.current;
1456
+ } = eagerValuesRef.current;
1448
1457
  const constraints = panelDataArray.map(({
1449
1458
  constraints
1450
1459
  }) => constraints);
@@ -1458,7 +1467,6 @@ function PanelGroupWithForwardedRef({
1458
1467
  const resizeObserver = new ResizeObserver(() => {
1459
1468
  const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
1460
1469
  const {
1461
- layout: prevLayout,
1462
1470
  onLayout
1463
1471
  } = committedValuesRef.current;
1464
1472
  const nextLayout = validatePanelGroupLayout({
@@ -1468,7 +1476,7 @@ function PanelGroupWithForwardedRef({
1468
1476
  });
1469
1477
  if (!areEqual(prevLayout, nextLayout)) {
1470
1478
  setLayout(nextLayout);
1471
- committedValuesRef.current.layout = nextLayout;
1479
+ eagerValuesRef.current.layout = nextLayout;
1472
1480
  if (onLayout) {
1473
1481
  onLayout(nextLayout.map(sizePercentage => ({
1474
1482
  sizePercentage,
@@ -1490,7 +1498,7 @@ function PanelGroupWithForwardedRef({
1490
1498
  {
1491
1499
  const {
1492
1500
  panelDataArray
1493
- } = committedValuesRef.current;
1501
+ } = eagerValuesRef.current;
1494
1502
  const {
1495
1503
  didLogIdAndOrderWarning,
1496
1504
  didLogPanelConstraintsWarning,
@@ -1533,11 +1541,13 @@ function PanelGroupWithForwardedRef({
1533
1541
 
1534
1542
  // External APIs are safe to memoize via committed values ref
1535
1543
  const collapsePanel = useCallback(panelData => {
1544
+ const {
1545
+ onLayout
1546
+ } = committedValuesRef.current;
1536
1547
  const {
1537
1548
  layout: prevLayout,
1538
- onLayout,
1539
1549
  panelDataArray
1540
- } = committedValuesRef.current;
1550
+ } = eagerValuesRef.current;
1541
1551
  if (panelData.constraints.collapsible) {
1542
1552
  const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1543
1553
  const {
@@ -1562,7 +1572,7 @@ function PanelGroupWithForwardedRef({
1562
1572
  });
1563
1573
  if (!compareLayouts(prevLayout, nextLayout)) {
1564
1574
  setLayout(nextLayout);
1565
- committedValuesRef.current.layout = nextLayout;
1575
+ eagerValuesRef.current.layout = nextLayout;
1566
1576
  if (onLayout) {
1567
1577
  onLayout(nextLayout.map(sizePercentage => ({
1568
1578
  sizePercentage,
@@ -1577,11 +1587,13 @@ function PanelGroupWithForwardedRef({
1577
1587
 
1578
1588
  // External APIs are safe to memoize via committed values ref
1579
1589
  const expandPanel = useCallback(panelData => {
1590
+ const {
1591
+ onLayout
1592
+ } = committedValuesRef.current;
1580
1593
  const {
1581
1594
  layout: prevLayout,
1582
- onLayout,
1583
1595
  panelDataArray
1584
- } = committedValuesRef.current;
1596
+ } = eagerValuesRef.current;
1585
1597
  if (panelData.constraints.collapsible) {
1586
1598
  const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1587
1599
  const {
@@ -1607,7 +1619,7 @@ function PanelGroupWithForwardedRef({
1607
1619
  });
1608
1620
  if (!compareLayouts(prevLayout, nextLayout)) {
1609
1621
  setLayout(nextLayout);
1610
- committedValuesRef.current.layout = nextLayout;
1622
+ eagerValuesRef.current.layout = nextLayout;
1611
1623
  if (onLayout) {
1612
1624
  onLayout(nextLayout.map(sizePercentage => ({
1613
1625
  sizePercentage,
@@ -1625,7 +1637,7 @@ function PanelGroupWithForwardedRef({
1625
1637
  const {
1626
1638
  layout,
1627
1639
  panelDataArray
1628
- } = committedValuesRef.current;
1640
+ } = eagerValuesRef.current;
1629
1641
  const {
1630
1642
  panelSizePercentage,
1631
1643
  panelSizePixels
@@ -1640,7 +1652,7 @@ function PanelGroupWithForwardedRef({
1640
1652
  const getPanelStyle = useCallback(panelData => {
1641
1653
  const {
1642
1654
  panelDataArray
1643
- } = committedValuesRef.current;
1655
+ } = eagerValuesRef.current;
1644
1656
  const panelIndex = panelDataArray.indexOf(panelData);
1645
1657
  return computePanelFlexBoxStyle({
1646
1658
  dragState,
@@ -1655,7 +1667,7 @@ function PanelGroupWithForwardedRef({
1655
1667
  const {
1656
1668
  layout,
1657
1669
  panelDataArray
1658
- } = committedValuesRef.current;
1670
+ } = eagerValuesRef.current;
1659
1671
  const {
1660
1672
  collapsedSizePercentage,
1661
1673
  collapsible,
@@ -1669,7 +1681,7 @@ function PanelGroupWithForwardedRef({
1669
1681
  const {
1670
1682
  layout,
1671
1683
  panelDataArray
1672
- } = committedValuesRef.current;
1684
+ } = eagerValuesRef.current;
1673
1685
  const {
1674
1686
  collapsedSizePercentage,
1675
1687
  collapsible,
@@ -1681,11 +1693,13 @@ function PanelGroupWithForwardedRef({
1681
1693
  const {
1682
1694
  autoSaveId,
1683
1695
  id: groupId,
1684
- layout: prevLayout,
1685
1696
  onLayout,
1686
- panelDataArray,
1687
1697
  storage
1688
1698
  } = committedValuesRef.current;
1699
+ const {
1700
+ layout: prevLayout,
1701
+ panelDataArray
1702
+ } = eagerValuesRef.current;
1689
1703
  panelDataArray.push(panelData);
1690
1704
  panelDataArray.sort((panelA, panelB) => {
1691
1705
  const orderA = panelA.order;
@@ -1737,9 +1751,13 @@ function PanelGroupWithForwardedRef({
1737
1751
  layout: unsafeLayout,
1738
1752
  panelConstraints: panelDataArray.map(panelData => panelData.constraints)
1739
1753
  });
1754
+
1755
+ // Offscreen mode makes this a bit weird;
1756
+ // Panels unregister when hidden and re-register when shown again,
1757
+ // but the overall layout doesn't change between these two cases.
1758
+ setLayout(nextLayout);
1759
+ eagerValuesRef.current.layout = nextLayout;
1740
1760
  if (!areEqual(prevLayout, nextLayout)) {
1741
- setLayout(nextLayout);
1742
- committedValuesRef.current.layout = nextLayout;
1743
1761
  if (onLayout) {
1744
1762
  onLayout(nextLayout.map(sizePercentage => ({
1745
1763
  sizePercentage,
@@ -1758,10 +1776,12 @@ function PanelGroupWithForwardedRef({
1758
1776
  id: groupId,
1759
1777
  keyboardResizeByPercentage,
1760
1778
  keyboardResizeByPixels,
1761
- onLayout,
1762
- panelDataArray,
1763
- layout: prevLayout
1779
+ onLayout
1764
1780
  } = committedValuesRef.current;
1781
+ const {
1782
+ layout: prevLayout,
1783
+ panelDataArray
1784
+ } = eagerValuesRef.current;
1765
1785
  const {
1766
1786
  initialLayout
1767
1787
  } = dragState !== null && dragState !== void 0 ? dragState : {};
@@ -1817,7 +1837,7 @@ function PanelGroupWithForwardedRef({
1817
1837
  }
1818
1838
  if (layoutChanged) {
1819
1839
  setLayout(nextLayout);
1820
- committedValuesRef.current.layout = nextLayout;
1840
+ eagerValuesRef.current.layout = nextLayout;
1821
1841
  if (onLayout) {
1822
1842
  onLayout(nextLayout.map(sizePercentage => ({
1823
1843
  sizePercentage,
@@ -1831,11 +1851,13 @@ function PanelGroupWithForwardedRef({
1831
1851
 
1832
1852
  // External APIs are safe to memoize via committed values ref
1833
1853
  const resizePanel = useCallback((panelData, mixedSizes) => {
1854
+ const {
1855
+ onLayout
1856
+ } = committedValuesRef.current;
1834
1857
  const {
1835
1858
  layout: prevLayout,
1836
- onLayout,
1837
1859
  panelDataArray
1838
- } = committedValuesRef.current;
1860
+ } = eagerValuesRef.current;
1839
1861
  const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1840
1862
  const {
1841
1863
  groupSizePixels,
@@ -1855,7 +1877,7 @@ function PanelGroupWithForwardedRef({
1855
1877
  });
1856
1878
  if (!compareLayouts(prevLayout, nextLayout)) {
1857
1879
  setLayout(nextLayout);
1858
- committedValuesRef.current.layout = nextLayout;
1880
+ eagerValuesRef.current.layout = nextLayout;
1859
1881
  if (onLayout) {
1860
1882
  onLayout(nextLayout.map(sizePercentage => ({
1861
1883
  sizePercentage,
@@ -1867,9 +1889,11 @@ function PanelGroupWithForwardedRef({
1867
1889
  }, [groupId]);
1868
1890
  const startDragging = useCallback((dragHandleId, event) => {
1869
1891
  const {
1870
- direction,
1871
- layout
1892
+ direction
1872
1893
  } = committedValuesRef.current;
1894
+ const {
1895
+ layout
1896
+ } = eagerValuesRef.current;
1873
1897
  const handleElement = getResizeHandleElement(dragHandleId);
1874
1898
  const initialCursorPosition = getResizeEventCursorPosition(direction, event);
1875
1899
  setDragState({
@@ -1890,10 +1914,12 @@ function PanelGroupWithForwardedRef({
1890
1914
  const unregisterPanel = useCallback(panelData => {
1891
1915
  const {
1892
1916
  id: groupId,
1917
+ onLayout
1918
+ } = committedValuesRef.current;
1919
+ const {
1893
1920
  layout: prevLayout,
1894
- onLayout,
1895
1921
  panelDataArray
1896
- } = committedValuesRef.current;
1922
+ } = eagerValuesRef.current;
1897
1923
  const index = panelDataArray.indexOf(panelData);
1898
1924
  if (index >= 0) {
1899
1925
  panelDataArray.splice(index, 1);
@@ -1910,7 +1936,7 @@ function PanelGroupWithForwardedRef({
1910
1936
  const {
1911
1937
  pendingPanelIds
1912
1938
  } = unregisterPanelRef.current;
1913
- panelIdToLastNotifiedMixedSizesMapRef.current;
1939
+ const map = panelIdToLastNotifiedMixedSizesMapRef.current;
1914
1940
 
1915
1941
  // TRICKY
1916
1942
  // Strict effects mode
@@ -1926,7 +1952,7 @@ function PanelGroupWithForwardedRef({
1926
1952
  // When a panel is removed from the group, we should delete the most recent prev-size entry for it.
1927
1953
  // If we don't do this, then a conditionally rendered panel might not call onResize when it's re-mounted.
1928
1954
  // Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
1929
- delete panelIdToLastNotifiedMixedSizesMapRef.current[panelData.id];
1955
+ delete map[panelData.id];
1930
1956
  }
1931
1957
  });
1932
1958
  if (!unmountDueToStrictMode) {
@@ -1951,7 +1977,7 @@ function PanelGroupWithForwardedRef({
1951
1977
  });
1952
1978
  if (!areEqual(prevLayout, nextLayout)) {
1953
1979
  setLayout(nextLayout);
1954
- committedValuesRef.current.layout = nextLayout;
1980
+ eagerValuesRef.current.layout = nextLayout;
1955
1981
  if (onLayout) {
1956
1982
  onLayout(nextLayout.map(sizePercentage => ({
1957
1983
  sizePercentage,