react-resizable-panels 2.0.8 → 2.0.10

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/declarations/src/utils/assert.d.ts +1 -1
  3. package/dist/react-resizable-panels.browser.cjs.js +158 -53
  4. package/dist/react-resizable-panels.browser.development.cjs.js +160 -55
  5. package/dist/react-resizable-panels.browser.development.esm.js +159 -54
  6. package/dist/react-resizable-panels.browser.esm.js +157 -52
  7. package/dist/react-resizable-panels.cjs.js +158 -53
  8. package/dist/react-resizable-panels.development.cjs.js +160 -55
  9. package/dist/react-resizable-panels.development.esm.js +159 -54
  10. package/dist/react-resizable-panels.development.node.cjs.js +156 -51
  11. package/dist/react-resizable-panels.development.node.esm.js +155 -50
  12. package/dist/react-resizable-panels.esm.js +157 -52
  13. package/dist/react-resizable-panels.node.cjs.js +154 -49
  14. package/dist/react-resizable-panels.node.esm.js +153 -48
  15. package/package.json +1 -4
  16. package/src/Panel.test.tsx +23 -23
  17. package/src/PanelGroup.test.tsx +32 -3
  18. package/src/PanelGroup.ts +25 -7
  19. package/src/PanelResizeHandle.test.tsx +3 -3
  20. package/src/PanelResizeHandle.ts +1 -1
  21. package/src/PanelResizeHandleRegistry.ts +2 -2
  22. package/src/hooks/useWindowSplitterBehavior.ts +5 -2
  23. package/src/hooks/useWindowSplitterPanelGroupBehavior.ts +5 -5
  24. package/src/utils/adjustLayoutByDelta.ts +47 -20
  25. package/src/utils/assert.ts +1 -1
  26. package/src/utils/calculateAriaValues.ts +1 -1
  27. package/src/utils/calculateDragOffsetPercentage.ts +6 -3
  28. package/src/utils/calculateUnsafeDefaultLayout.ts +2 -2
  29. package/src/utils/callPanelCallbacks.ts +1 -1
  30. package/src/utils/resizePanel.ts +4 -1
  31. package/src/utils/test-utils.ts +1 -1
  32. package/src/utils/validatePanelConstraints.ts +4 -1
  33. package/src/utils/validatePanelGroupLayout.ts +3 -3
  34. package/src/vendor/stacking-order.ts +133 -0
@@ -1,5 +1,4 @@
1
1
  import * as React from 'react';
2
- import { compare } from 'stacking-order';
3
2
 
4
3
  const isBrowser = typeof window !== "undefined";
5
4
 
@@ -293,6 +292,114 @@ function intersects(rectOne, rectTwo, strict) {
293
292
  }
294
293
  }
295
294
 
295
+ // Forked from NPM stacking-order@2.0.0
296
+
297
+ /**
298
+ * Determine which of two nodes appears in front of the other —
299
+ * if `a` is in front, returns 1, otherwise returns -1
300
+ * @param {HTMLElement} a
301
+ * @param {HTMLElement} b
302
+ */
303
+ function compare(a, b) {
304
+ if (a === b) throw new Error("Cannot compare node with itself");
305
+ const ancestors = {
306
+ a: get_ancestors(a),
307
+ b: get_ancestors(b)
308
+ };
309
+ let common_ancestor;
310
+
311
+ // remove shared ancestors
312
+ while (ancestors.a.at(-1) === ancestors.b.at(-1)) {
313
+ a = ancestors.a.pop();
314
+ b = ancestors.b.pop();
315
+ common_ancestor = a;
316
+ }
317
+ assert(common_ancestor, "Stacking order can only be calculated for elements with a common ancestor");
318
+ const z_indexes = {
319
+ a: get_z_index(find_stacking_context(ancestors.a)),
320
+ b: get_z_index(find_stacking_context(ancestors.b))
321
+ };
322
+ if (z_indexes.a === z_indexes.b) {
323
+ const children = common_ancestor.childNodes;
324
+ const furthest_ancestors = {
325
+ a: ancestors.a.at(-1),
326
+ b: ancestors.b.at(-1)
327
+ };
328
+ let i = children.length;
329
+ while (i--) {
330
+ const child = children[i];
331
+ if (child === furthest_ancestors.a) return 1;
332
+ if (child === furthest_ancestors.b) return -1;
333
+ }
334
+ }
335
+ return Math.sign(z_indexes.a - z_indexes.b);
336
+ }
337
+ const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
338
+
339
+ /** @param {HTMLElement} node */
340
+ function is_flex_item(node) {
341
+ const display = getComputedStyle(get_parent(node)).display;
342
+ return display === "flex" || display === "inline-flex";
343
+ }
344
+
345
+ /** @param {HTMLElement} node */
346
+ function creates_stacking_context(node) {
347
+ const style = getComputedStyle(node);
348
+
349
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
350
+ if (style.position === "fixed") return true;
351
+ // Forked to fix upstream bug https://github.com/Rich-Harris/stacking-order/issues/3
352
+ // if (
353
+ // (style.zIndex !== "auto" && style.position !== "static") ||
354
+ // is_flex_item(node)
355
+ // )
356
+ if (style.zIndex !== "auto" && (style.position !== "static" || is_flex_item(node))) return true;
357
+ if (+style.opacity < 1) return true;
358
+ if ("transform" in style && style.transform !== "none") return true;
359
+ if ("webkitTransform" in style && style.webkitTransform !== "none") return true;
360
+ if ("mixBlendMode" in style && style.mixBlendMode !== "normal") return true;
361
+ if ("filter" in style && style.filter !== "none") return true;
362
+ if ("webkitFilter" in style && style.webkitFilter !== "none") return true;
363
+ if ("isolation" in style && style.isolation === "isolate") return true;
364
+ if (props.test(style.willChange)) return true;
365
+ // @ts-expect-error
366
+ if (style.webkitOverflowScrolling === "touch") return true;
367
+ return false;
368
+ }
369
+
370
+ /** @param {HTMLElement[]} nodes */
371
+ function find_stacking_context(nodes) {
372
+ let i = nodes.length;
373
+ while (i--) {
374
+ const node = nodes[i];
375
+ assert(node, "Missing node");
376
+ if (creates_stacking_context(node)) return node;
377
+ }
378
+ return null;
379
+ }
380
+
381
+ /** @param {HTMLElement} node */
382
+ function get_z_index(node) {
383
+ return node && Number(getComputedStyle(node).zIndex) || 0;
384
+ }
385
+
386
+ /** @param {HTMLElement} node */
387
+ function get_ancestors(node) {
388
+ const ancestors = [];
389
+ while (node) {
390
+ ancestors.push(node);
391
+ node = get_parent(node);
392
+ }
393
+ return ancestors; // [ node, ... <body>, <html>, document ]
394
+ }
395
+
396
+ /** @param {HTMLElement} node */
397
+ function get_parent(node) {
398
+ var _node$parentNode;
399
+ // @ts-ignore
400
+ return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
401
+ }
402
+
296
403
  const EXCEEDED_HORIZONTAL_MIN = 0b0001;
297
404
  const EXCEEDED_HORIZONTAL_MAX = 0b0010;
298
405
  const EXCEEDED_VERTICAL_MIN = 0b0100;
@@ -505,7 +612,7 @@ function updateListeners() {
505
612
  window.removeEventListener("mouseup", handlePointerUp);
506
613
  window.removeEventListener("touchcancel", handlePointerUp);
507
614
  window.removeEventListener("touchend", handlePointerUp);
508
- if (registerResizeHandle.length > 0) {
615
+ if (registeredResizeHandlers.size > 0) {
509
616
  if (isPointerDown) {
510
617
  if (intersectingHandles.length > 0) {
511
618
  ownerDocumentCounts.forEach((count, ownerDocument) => {
@@ -552,7 +659,7 @@ function updateResizeHandlerStates(action, event) {
552
659
  });
553
660
  }
554
661
 
555
- function assert(expectedCondition, message = "Assertion failed!") {
662
+ function assert(expectedCondition, message) {
556
663
  if (!expectedCondition) {
557
664
  console.error(message);
558
665
  throw Error(message);
@@ -583,7 +690,7 @@ function resizePanel({
583
690
  size
584
691
  }) {
585
692
  const panelConstraints = panelConstraintsArray[panelIndex];
586
- assert(panelConstraints != null);
693
+ assert(panelConstraints != null, `Panel constraints not found for index ${panelIndex}`);
587
694
  let {
588
695
  collapsedSize = 0,
589
696
  collapsible,
@@ -621,8 +728,8 @@ function adjustLayoutByDelta({
621
728
  }
622
729
  const nextLayout = [...prevLayout];
623
730
  const [firstPivotIndex, secondPivotIndex] = pivotIndices;
624
- assert(firstPivotIndex != null);
625
- assert(secondPivotIndex != null);
731
+ assert(firstPivotIndex != null, "Invalid first pivot index");
732
+ assert(secondPivotIndex != null, "Invalid second pivot index");
626
733
  let deltaApplied = 0;
627
734
 
628
735
  //const DEBUG = [];
@@ -648,19 +755,18 @@ function adjustLayoutByDelta({
648
755
  // Check if we should expand a collapsed panel
649
756
  const index = delta < 0 ? secondPivotIndex : firstPivotIndex;
650
757
  const panelConstraints = panelConstraintsArray[index];
651
- assert(panelConstraints);
758
+ assert(panelConstraints, `Panel constraints not found for index ${index}`);
759
+ const {
760
+ collapsedSize = 0,
761
+ collapsible,
762
+ minSize = 0
763
+ } = panelConstraints;
652
764
 
653
765
  //DEBUG.push(`edge case check 1: ${index}`);
654
766
  //DEBUG.push(` -> collapsible? ${constraints.collapsible}`);
655
- if (panelConstraints.collapsible) {
767
+ if (collapsible) {
656
768
  const prevSize = prevLayout[index];
657
- assert(prevSize != null);
658
- const panelConstraints = panelConstraintsArray[index];
659
- assert(panelConstraints);
660
- const {
661
- collapsedSize = 0,
662
- minSize = 0
663
- } = panelConstraints;
769
+ assert(prevSize != null, `Previous layout not found for panel index ${index}`);
664
770
  if (fuzzyNumbersEqual(prevSize, collapsedSize)) {
665
771
  const localDelta = minSize - prevSize;
666
772
  //DEBUG.push(` -> expand delta: ${localDelta}`);
@@ -677,22 +783,18 @@ function adjustLayoutByDelta({
677
783
  // Check if we should collapse a panel at its minimum size
678
784
  const index = delta < 0 ? firstPivotIndex : secondPivotIndex;
679
785
  const panelConstraints = panelConstraintsArray[index];
680
- assert(panelConstraints);
786
+ assert(panelConstraints, `No panel constraints found for index ${index}`);
681
787
  const {
682
- collapsible
788
+ collapsedSize = 0,
789
+ collapsible,
790
+ minSize = 0
683
791
  } = panelConstraints;
684
792
 
685
793
  //DEBUG.push(`edge case check 2: ${index}`);
686
794
  //DEBUG.push(` -> collapsible? ${collapsible}`);
687
795
  if (collapsible) {
688
796
  const prevSize = prevLayout[index];
689
- assert(prevSize != null);
690
- const panelConstraints = panelConstraintsArray[index];
691
- assert(panelConstraints);
692
- const {
693
- collapsedSize = 0,
694
- minSize = 0
695
- } = panelConstraints;
797
+ assert(prevSize != null, `Previous layout not found for panel index ${index}`);
696
798
  if (fuzzyNumbersEqual(prevSize, minSize)) {
697
799
  const localDelta = prevSize - collapsedSize;
698
800
  //DEBUG.push(` -> expand delta: ${localDelta}`);
@@ -722,7 +824,7 @@ function adjustLayoutByDelta({
722
824
  //DEBUG.push("pre calc...");
723
825
  while (true) {
724
826
  const prevSize = prevLayout[index];
725
- assert(prevSize != null);
827
+ assert(prevSize != null, `Previous layout not found for panel index ${index}`);
726
828
  const maxSafeSize = resizePanel({
727
829
  panelConstraints: panelConstraintsArray,
728
830
  panelIndex: index,
@@ -753,7 +855,7 @@ function adjustLayoutByDelta({
753
855
  while (index >= 0 && index < panelConstraintsArray.length) {
754
856
  const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
755
857
  const prevSize = prevLayout[index];
756
- assert(prevSize != null);
858
+ assert(prevSize != null, `Previous layout not found for panel index ${index}`);
757
859
  const unsafeSize = prevSize - deltaRemaining;
758
860
  const safeSize = resizePanel({
759
861
  panelConstraints: panelConstraintsArray,
@@ -790,7 +892,7 @@ function adjustLayoutByDelta({
790
892
  // Now distribute the applied delta to the panels in the other direction
791
893
  const pivotIndex = delta < 0 ? secondPivotIndex : firstPivotIndex;
792
894
  const prevSize = prevLayout[pivotIndex];
793
- assert(prevSize != null);
895
+ assert(prevSize != null, `Previous layout not found for panel index ${pivotIndex}`);
794
896
  const unsafeSize = prevSize + deltaApplied;
795
897
  const safeSize = resizePanel({
796
898
  panelConstraints: panelConstraintsArray,
@@ -808,7 +910,7 @@ function adjustLayoutByDelta({
808
910
  let index = pivotIndex;
809
911
  while (index >= 0 && index < panelConstraintsArray.length) {
810
912
  const prevSize = nextLayout[index];
811
- assert(prevSize != null);
913
+ assert(prevSize != null, `Previous layout not found for panel index ${index}`);
812
914
  const unsafeSize = prevSize + deltaRemaining;
813
915
  const safeSize = resizePanel({
814
916
  panelConstraints: panelConstraintsArray,
@@ -854,7 +956,7 @@ function calculateAriaValues({
854
956
  let totalMinSize = 0;
855
957
  let totalMaxSize = 0;
856
958
  const firstIndex = pivotIndices[0];
857
- assert(firstIndex != null);
959
+ assert(firstIndex != null, "No pivot index found");
858
960
 
859
961
  // A panel's effective min/max sizes also need to account for other panel's sizes.
860
962
  panelsArray.forEach((panelData, index) => {
@@ -973,7 +1075,7 @@ function useWindowSplitterPanelGroupBehavior({
973
1075
  }
974
1076
  } else {
975
1077
  const panelData = panelDataArray[index];
976
- assert(panelData);
1078
+ assert(panelData, `No panel data found for index "${index}"`);
977
1079
  resizeHandleElement.setAttribute("aria-controls", panelData.id);
978
1080
  resizeHandleElement.setAttribute("aria-valuemax", "" + Math.round(valueMax));
979
1081
  resizeHandleElement.setAttribute("aria-valuemin", "" + Math.round(valueMin));
@@ -994,17 +1096,17 @@ function useWindowSplitterPanelGroupBehavior({
994
1096
  return;
995
1097
  }
996
1098
  const eagerValues = eagerValuesRef.current;
997
- assert(eagerValues);
1099
+ assert(eagerValues, `Eager values not found`);
998
1100
  const {
999
1101
  panelDataArray
1000
1102
  } = eagerValues;
1001
1103
  const groupElement = getPanelGroupElement(groupId, panelGroupElement);
1002
1104
  assert(groupElement != null, `No group found for id "${groupId}"`);
1003
1105
  const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
1004
- assert(handles);
1106
+ assert(handles, `No resize handles found for group id "${groupId}"`);
1005
1107
  const cleanupFunctions = handles.map(handle => {
1006
1108
  const handleId = handle.getAttribute("data-panel-resize-handle-id");
1007
- assert(handleId);
1109
+ assert(handleId, `Resize handle element has no handle id attribute`);
1008
1110
  const [idBefore, idAfter] = getResizeHandlePanelIds(groupId, handleId, panelDataArray, panelGroupElement);
1009
1111
  if (idBefore == null || idAfter == null) {
1010
1112
  return () => {};
@@ -1020,7 +1122,7 @@ function useWindowSplitterPanelGroupBehavior({
1020
1122
  const index = panelDataArray.findIndex(panelData => panelData.id === idBefore);
1021
1123
  if (index >= 0) {
1022
1124
  const panelData = panelDataArray[index];
1023
- assert(panelData);
1125
+ assert(panelData, `No panel data found for index ${index}`);
1024
1126
  const size = layout[index];
1025
1127
  const {
1026
1128
  collapsedSize = 0,
@@ -1079,15 +1181,15 @@ function getResizeEventCursorPosition(direction, event) {
1079
1181
  function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState, panelGroupElement) {
1080
1182
  const isHorizontal = direction === "horizontal";
1081
1183
  const handleElement = getResizeHandleElement(dragHandleId, panelGroupElement);
1082
- assert(handleElement);
1184
+ assert(handleElement, `No resize handle element found for id "${dragHandleId}"`);
1083
1185
  const groupId = handleElement.getAttribute("data-panel-group-id");
1084
- assert(groupId);
1186
+ assert(groupId, `Resize handle element has no group id attribute`);
1085
1187
  let {
1086
1188
  initialCursorPosition
1087
1189
  } = initialDragState;
1088
1190
  const cursorPosition = getResizeEventCursorPosition(direction, event);
1089
1191
  const groupElement = getPanelGroupElement(groupId, panelGroupElement);
1090
- assert(groupElement);
1192
+ assert(groupElement, `No group element found for id "${groupId}"`);
1091
1193
  const groupRect = groupElement.getBoundingClientRect();
1092
1194
  const groupSizeInPixels = isHorizontal ? groupRect.width : groupRect.height;
1093
1195
  const offsetPixels = cursorPosition - initialCursorPosition;
@@ -1148,7 +1250,7 @@ function calculateUnsafeDefaultLayout({
1148
1250
  // Distribute default sizes first
1149
1251
  for (let index = 0; index < panelDataArray.length; index++) {
1150
1252
  const panelConstraints = panelConstraintsArray[index];
1151
- assert(panelConstraints);
1253
+ assert(panelConstraints, `Panel constraints not found for index ${index}`);
1152
1254
  const {
1153
1255
  defaultSize
1154
1256
  } = panelConstraints;
@@ -1162,7 +1264,7 @@ function calculateUnsafeDefaultLayout({
1162
1264
  // Remaining size should be distributed evenly between panels without default sizes
1163
1265
  for (let index = 0; index < panelDataArray.length; index++) {
1164
1266
  const panelConstraints = panelConstraintsArray[index];
1165
- assert(panelConstraints);
1267
+ assert(panelConstraints, `Panel constraints not found for index ${index}`);
1166
1268
  const {
1167
1269
  defaultSize
1168
1270
  } = panelConstraints;
@@ -1182,7 +1284,7 @@ function calculateUnsafeDefaultLayout({
1182
1284
  function callPanelCallbacks(panelsArray, layout, panelIdToLastNotifiedSizeMap) {
1183
1285
  layout.forEach((size, index) => {
1184
1286
  const panelData = panelsArray[index];
1185
- assert(panelData);
1287
+ assert(panelData, `Panel data not found for index ${index}`);
1186
1288
  const {
1187
1289
  callbacks,
1188
1290
  constraints,
@@ -1366,7 +1468,7 @@ function validatePanelConstraints({
1366
1468
  {
1367
1469
  const warnings = [];
1368
1470
  const panelConstraints = panelConstraintsArray[panelIndex];
1369
- assert(panelConstraints);
1471
+ assert(panelConstraints, `No panel constraints found for index ${panelIndex}`);
1370
1472
  const {
1371
1473
  collapsedSize = 0,
1372
1474
  collapsible = false,
@@ -1420,7 +1522,7 @@ function validatePanelGroupLayout({
1420
1522
  }
1421
1523
  for (let index = 0; index < panelConstraints.length; index++) {
1422
1524
  const unsafeSize = nextLayout[index];
1423
- assert(unsafeSize != null);
1525
+ assert(unsafeSize != null, `No layout data found for index ${index}`);
1424
1526
  const safeSize = 100 / nextLayoutTotalSize * unsafeSize;
1425
1527
  nextLayout[index] = safeSize;
1426
1528
  }
@@ -1430,7 +1532,7 @@ function validatePanelGroupLayout({
1430
1532
  // First pass: Validate the proposed layout given each panel's constraints
1431
1533
  for (let index = 0; index < panelConstraints.length; index++) {
1432
1534
  const unsafeSize = nextLayout[index];
1433
- assert(unsafeSize != null);
1535
+ assert(unsafeSize != null, `No layout data found for index ${index}`);
1434
1536
  const safeSize = resizePanel({
1435
1537
  panelConstraints,
1436
1538
  panelIndex: index,
@@ -1447,7 +1549,7 @@ function validatePanelGroupLayout({
1447
1549
  if (!fuzzyNumbersEqual(remainingSize, 0)) {
1448
1550
  for (let index = 0; index < panelConstraints.length; index++) {
1449
1551
  const prevSize = nextLayout[index];
1450
- assert(prevSize != null);
1552
+ assert(prevSize != null, `No layout data found for index ${index}`);
1451
1553
  const unsafeSize = prevSize + remainingSize;
1452
1554
  const safeSize = resizePanel({
1453
1555
  panelConstraints,
@@ -1624,7 +1726,7 @@ function PanelGroupWithForwardedRef({
1624
1726
  const panelConstraints = panelDataArray.map(panelData => panelData.constraints);
1625
1727
  for (let panelIndex = 0; panelIndex < panelConstraints.length; panelIndex++) {
1626
1728
  const panelData = panelDataArray[panelIndex];
1627
- assert(panelData);
1729
+ assert(panelData, `Panel data not found for index ${panelIndex}`);
1628
1730
  const isValid = validatePanelConstraints({
1629
1731
  panelConstraints,
1630
1732
  panelId: panelData.id,
@@ -1655,7 +1757,7 @@ function PanelGroupWithForwardedRef({
1655
1757
  panelSize,
1656
1758
  pivotIndices
1657
1759
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1658
- assert(panelSize != null);
1760
+ assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1659
1761
  if (panelSize !== collapsedSize) {
1660
1762
  // Store size before collapse;
1661
1763
  // This is the size that gets restored if the expand() API is used.
@@ -1732,7 +1834,7 @@ function PanelGroupWithForwardedRef({
1732
1834
  const {
1733
1835
  panelSize
1734
1836
  } = panelDataHelper(panelDataArray, panelData, layout);
1735
- assert(panelSize != null);
1837
+ assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1736
1838
  return panelSize;
1737
1839
  }, []);
1738
1840
 
@@ -1776,7 +1878,7 @@ function PanelGroupWithForwardedRef({
1776
1878
  collapsible,
1777
1879
  panelSize
1778
1880
  } = panelDataHelper(panelDataArray, panelData, layout);
1779
- assert(panelSize != null);
1881
+ assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1780
1882
  return !collapsible || panelSize > collapsedSize;
1781
1883
  }, []);
1782
1884
  const registerPanel = useCallback(panelData => {
@@ -1943,7 +2045,7 @@ function PanelGroupWithForwardedRef({
1943
2045
  panelSize,
1944
2046
  pivotIndices
1945
2047
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1946
- assert(panelSize != null);
2048
+ assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1947
2049
  const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
1948
2050
  const delta = isLastPanel ? panelSize - unsafePanelSize : unsafePanelSize - panelSize;
1949
2051
  const nextLayout = adjustLayoutByDelta({
@@ -1980,7 +2082,10 @@ function PanelGroupWithForwardedRef({
1980
2082
  const {
1981
2083
  panelSize: prevPanelSize
1982
2084
  } = panelDataHelper(panelDataArray, panelData, layout);
1983
- assert(prevPanelSize != null);
2085
+ if (prevPanelSize == null) {
2086
+ // It's possible that the panels in this group have changed since the last render
2087
+ return;
2088
+ }
1984
2089
  if (prevCollapsible && nextCollapsible && prevPanelSize === prevCollapsedSize) {
1985
2090
  if (prevCollapsedSize !== nextCollapsedSize) {
1986
2091
  resizePanel(panelData, nextCollapsedSize);
@@ -2002,7 +2107,7 @@ function PanelGroupWithForwardedRef({
2002
2107
  return;
2003
2108
  }
2004
2109
  const handleElement = getResizeHandleElement(dragHandleId, panelGroupElementRef.current);
2005
- assert(handleElement);
2110
+ assert(handleElement, `Drag handle element not found for id "${dragHandleId}"`);
2006
2111
  const initialCursorPosition = getResizeEventCursorPosition(direction, event);
2007
2112
  setDragState({
2008
2113
  dragHandleId,
@@ -2131,10 +2236,10 @@ function useWindowSplitterResizeHandlerBehavior({
2131
2236
  {
2132
2237
  event.preventDefault();
2133
2238
  const groupId = handleElement.getAttribute("data-panel-group-id");
2134
- assert(groupId);
2239
+ assert(groupId, `No group element found for id "${groupId}"`);
2135
2240
  const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
2136
2241
  const index = getResizeHandleElementIndex(groupId, handleId, panelGroupElement);
2137
- assert(index !== null);
2242
+ assert(index !== null, `No resize element found for id "${handleId}"`);
2138
2243
  const nextIndex = event.shiftKey ? index > 0 ? index - 1 : handles.length - 1 : index + 1 < handles.length ? index + 1 : 0;
2139
2244
  const nextHandle = handles[nextIndex];
2140
2245
  nextHandle.focus();
@@ -2206,7 +2311,7 @@ function PanelResizeHandle({
2206
2311
  return;
2207
2312
  }
2208
2313
  const element = elementRef.current;
2209
- assert(element);
2314
+ assert(element, "Element ref not attached");
2210
2315
  const setResizeHandlerState = (action, isActive, event) => {
2211
2316
  if (isActive) {
2212
2317
  switch (action) {