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
@@ -3,7 +3,6 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
- var stackingOrder = require('stacking-order');
7
6
 
8
7
  function _interopNamespace(e) {
9
8
  if (e && e.__esModule) return e;
@@ -310,6 +309,114 @@ function intersects(rectOne, rectTwo, strict) {
310
309
  }
311
310
  }
312
311
 
312
+ // Forked from NPM stacking-order@2.0.0
313
+
314
+ /**
315
+ * Determine which of two nodes appears in front of the other —
316
+ * if `a` is in front, returns 1, otherwise returns -1
317
+ * @param {HTMLElement} a
318
+ * @param {HTMLElement} b
319
+ */
320
+ function compare(a, b) {
321
+ if (a === b) throw new Error("Cannot compare node with itself");
322
+ const ancestors = {
323
+ a: get_ancestors(a),
324
+ b: get_ancestors(b)
325
+ };
326
+ let common_ancestor;
327
+
328
+ // remove shared ancestors
329
+ while (ancestors.a.at(-1) === ancestors.b.at(-1)) {
330
+ a = ancestors.a.pop();
331
+ b = ancestors.b.pop();
332
+ common_ancestor = a;
333
+ }
334
+ assert(common_ancestor, "Stacking order can only be calculated for elements with a common ancestor");
335
+ const z_indexes = {
336
+ a: get_z_index(find_stacking_context(ancestors.a)),
337
+ b: get_z_index(find_stacking_context(ancestors.b))
338
+ };
339
+ if (z_indexes.a === z_indexes.b) {
340
+ const children = common_ancestor.childNodes;
341
+ const furthest_ancestors = {
342
+ a: ancestors.a.at(-1),
343
+ b: ancestors.b.at(-1)
344
+ };
345
+ let i = children.length;
346
+ while (i--) {
347
+ const child = children[i];
348
+ if (child === furthest_ancestors.a) return 1;
349
+ if (child === furthest_ancestors.b) return -1;
350
+ }
351
+ }
352
+ return Math.sign(z_indexes.a - z_indexes.b);
353
+ }
354
+ const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
355
+
356
+ /** @param {HTMLElement} node */
357
+ function is_flex_item(node) {
358
+ const display = getComputedStyle(get_parent(node)).display;
359
+ return display === "flex" || display === "inline-flex";
360
+ }
361
+
362
+ /** @param {HTMLElement} node */
363
+ function creates_stacking_context(node) {
364
+ const style = getComputedStyle(node);
365
+
366
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
367
+ if (style.position === "fixed") return true;
368
+ // Forked to fix upstream bug https://github.com/Rich-Harris/stacking-order/issues/3
369
+ // if (
370
+ // (style.zIndex !== "auto" && style.position !== "static") ||
371
+ // is_flex_item(node)
372
+ // )
373
+ if (style.zIndex !== "auto" && (style.position !== "static" || is_flex_item(node))) return true;
374
+ if (+style.opacity < 1) return true;
375
+ if ("transform" in style && style.transform !== "none") return true;
376
+ if ("webkitTransform" in style && style.webkitTransform !== "none") return true;
377
+ if ("mixBlendMode" in style && style.mixBlendMode !== "normal") return true;
378
+ if ("filter" in style && style.filter !== "none") return true;
379
+ if ("webkitFilter" in style && style.webkitFilter !== "none") return true;
380
+ if ("isolation" in style && style.isolation === "isolate") return true;
381
+ if (props.test(style.willChange)) return true;
382
+ // @ts-expect-error
383
+ if (style.webkitOverflowScrolling === "touch") return true;
384
+ return false;
385
+ }
386
+
387
+ /** @param {HTMLElement[]} nodes */
388
+ function find_stacking_context(nodes) {
389
+ let i = nodes.length;
390
+ while (i--) {
391
+ const node = nodes[i];
392
+ assert(node, "Missing node");
393
+ if (creates_stacking_context(node)) return node;
394
+ }
395
+ return null;
396
+ }
397
+
398
+ /** @param {HTMLElement} node */
399
+ function get_z_index(node) {
400
+ return node && Number(getComputedStyle(node).zIndex) || 0;
401
+ }
402
+
403
+ /** @param {HTMLElement} node */
404
+ function get_ancestors(node) {
405
+ const ancestors = [];
406
+ while (node) {
407
+ ancestors.push(node);
408
+ node = get_parent(node);
409
+ }
410
+ return ancestors; // [ node, ... <body>, <html>, document ]
411
+ }
412
+
413
+ /** @param {HTMLElement} node */
414
+ function get_parent(node) {
415
+ var _node$parentNode;
416
+ // @ts-ignore
417
+ return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
418
+ }
419
+
313
420
  const EXCEEDED_HORIZONTAL_MIN = 0b0001;
314
421
  const EXCEEDED_HORIZONTAL_MAX = 0b0010;
315
422
  const EXCEEDED_VERTICAL_MIN = 0b0100;
@@ -451,7 +558,7 @@ function recalculateIntersectingHandles({
451
558
  // Calculating stacking order has a cost, so we should avoid it if possible
452
559
  // That is why we only check potentially intersecting handles,
453
560
  // and why we skip if the event target is within the handle's DOM
454
- stackingOrder.compare(targetElement, dragHandleElement) > 0) {
561
+ compare(targetElement, dragHandleElement) > 0) {
455
562
  // If the target is above the drag handle, then we also need to confirm they overlap
456
563
  // If they are beside each other (e.g. a panel and its drag handle) then the handle is still interactive
457
564
  //
@@ -522,7 +629,7 @@ function updateListeners() {
522
629
  window.removeEventListener("mouseup", handlePointerUp);
523
630
  window.removeEventListener("touchcancel", handlePointerUp);
524
631
  window.removeEventListener("touchend", handlePointerUp);
525
- if (registerResizeHandle.length > 0) {
632
+ if (registeredResizeHandlers.size > 0) {
526
633
  if (isPointerDown) {
527
634
  if (intersectingHandles.length > 0) {
528
635
  ownerDocumentCounts.forEach((count, ownerDocument) => {
@@ -569,7 +676,7 @@ function updateResizeHandlerStates(action, event) {
569
676
  });
570
677
  }
571
678
 
572
- function assert(expectedCondition, message = "Assertion failed!") {
679
+ function assert(expectedCondition, message) {
573
680
  if (!expectedCondition) {
574
681
  console.error(message);
575
682
  throw Error(message);
@@ -600,7 +707,7 @@ function resizePanel({
600
707
  size
601
708
  }) {
602
709
  const panelConstraints = panelConstraintsArray[panelIndex];
603
- assert(panelConstraints != null);
710
+ assert(panelConstraints != null, `Panel constraints not found for index ${panelIndex}`);
604
711
  let {
605
712
  collapsedSize = 0,
606
713
  collapsible,
@@ -638,8 +745,8 @@ function adjustLayoutByDelta({
638
745
  }
639
746
  const nextLayout = [...prevLayout];
640
747
  const [firstPivotIndex, secondPivotIndex] = pivotIndices;
641
- assert(firstPivotIndex != null);
642
- assert(secondPivotIndex != null);
748
+ assert(firstPivotIndex != null, "Invalid first pivot index");
749
+ assert(secondPivotIndex != null, "Invalid second pivot index");
643
750
  let deltaApplied = 0;
644
751
 
645
752
  //const DEBUG = [];
@@ -665,19 +772,18 @@ function adjustLayoutByDelta({
665
772
  // Check if we should expand a collapsed panel
666
773
  const index = delta < 0 ? secondPivotIndex : firstPivotIndex;
667
774
  const panelConstraints = panelConstraintsArray[index];
668
- assert(panelConstraints);
775
+ assert(panelConstraints, `Panel constraints not found for index ${index}`);
776
+ const {
777
+ collapsedSize = 0,
778
+ collapsible,
779
+ minSize = 0
780
+ } = panelConstraints;
669
781
 
670
782
  //DEBUG.push(`edge case check 1: ${index}`);
671
783
  //DEBUG.push(` -> collapsible? ${constraints.collapsible}`);
672
- if (panelConstraints.collapsible) {
784
+ if (collapsible) {
673
785
  const prevSize = prevLayout[index];
674
- assert(prevSize != null);
675
- const panelConstraints = panelConstraintsArray[index];
676
- assert(panelConstraints);
677
- const {
678
- collapsedSize = 0,
679
- minSize = 0
680
- } = panelConstraints;
786
+ assert(prevSize != null, `Previous layout not found for panel index ${index}`);
681
787
  if (fuzzyNumbersEqual(prevSize, collapsedSize)) {
682
788
  const localDelta = minSize - prevSize;
683
789
  //DEBUG.push(` -> expand delta: ${localDelta}`);
@@ -694,22 +800,18 @@ function adjustLayoutByDelta({
694
800
  // Check if we should collapse a panel at its minimum size
695
801
  const index = delta < 0 ? firstPivotIndex : secondPivotIndex;
696
802
  const panelConstraints = panelConstraintsArray[index];
697
- assert(panelConstraints);
803
+ assert(panelConstraints, `No panel constraints found for index ${index}`);
698
804
  const {
699
- collapsible
805
+ collapsedSize = 0,
806
+ collapsible,
807
+ minSize = 0
700
808
  } = panelConstraints;
701
809
 
702
810
  //DEBUG.push(`edge case check 2: ${index}`);
703
811
  //DEBUG.push(` -> collapsible? ${collapsible}`);
704
812
  if (collapsible) {
705
813
  const prevSize = prevLayout[index];
706
- assert(prevSize != null);
707
- const panelConstraints = panelConstraintsArray[index];
708
- assert(panelConstraints);
709
- const {
710
- collapsedSize = 0,
711
- minSize = 0
712
- } = panelConstraints;
814
+ assert(prevSize != null, `Previous layout not found for panel index ${index}`);
713
815
  if (fuzzyNumbersEqual(prevSize, minSize)) {
714
816
  const localDelta = prevSize - collapsedSize;
715
817
  //DEBUG.push(` -> expand delta: ${localDelta}`);
@@ -739,7 +841,7 @@ function adjustLayoutByDelta({
739
841
  //DEBUG.push("pre calc...");
740
842
  while (true) {
741
843
  const prevSize = prevLayout[index];
742
- assert(prevSize != null);
844
+ assert(prevSize != null, `Previous layout not found for panel index ${index}`);
743
845
  const maxSafeSize = resizePanel({
744
846
  panelConstraints: panelConstraintsArray,
745
847
  panelIndex: index,
@@ -770,7 +872,7 @@ function adjustLayoutByDelta({
770
872
  while (index >= 0 && index < panelConstraintsArray.length) {
771
873
  const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
772
874
  const prevSize = prevLayout[index];
773
- assert(prevSize != null);
875
+ assert(prevSize != null, `Previous layout not found for panel index ${index}`);
774
876
  const unsafeSize = prevSize - deltaRemaining;
775
877
  const safeSize = resizePanel({
776
878
  panelConstraints: panelConstraintsArray,
@@ -807,7 +909,7 @@ function adjustLayoutByDelta({
807
909
  // Now distribute the applied delta to the panels in the other direction
808
910
  const pivotIndex = delta < 0 ? secondPivotIndex : firstPivotIndex;
809
911
  const prevSize = prevLayout[pivotIndex];
810
- assert(prevSize != null);
912
+ assert(prevSize != null, `Previous layout not found for panel index ${pivotIndex}`);
811
913
  const unsafeSize = prevSize + deltaApplied;
812
914
  const safeSize = resizePanel({
813
915
  panelConstraints: panelConstraintsArray,
@@ -825,7 +927,7 @@ function adjustLayoutByDelta({
825
927
  let index = pivotIndex;
826
928
  while (index >= 0 && index < panelConstraintsArray.length) {
827
929
  const prevSize = nextLayout[index];
828
- assert(prevSize != null);
930
+ assert(prevSize != null, `Previous layout not found for panel index ${index}`);
829
931
  const unsafeSize = prevSize + deltaRemaining;
830
932
  const safeSize = resizePanel({
831
933
  panelConstraints: panelConstraintsArray,
@@ -871,7 +973,7 @@ function calculateAriaValues({
871
973
  let totalMinSize = 0;
872
974
  let totalMaxSize = 0;
873
975
  const firstIndex = pivotIndices[0];
874
- assert(firstIndex != null);
976
+ assert(firstIndex != null, "No pivot index found");
875
977
 
876
978
  // A panel's effective min/max sizes also need to account for other panel's sizes.
877
979
  panelsArray.forEach((panelData, index) => {
@@ -990,7 +1092,7 @@ function useWindowSplitterPanelGroupBehavior({
990
1092
  }
991
1093
  } else {
992
1094
  const panelData = panelDataArray[index];
993
- assert(panelData);
1095
+ assert(panelData, `No panel data found for index "${index}"`);
994
1096
  resizeHandleElement.setAttribute("aria-controls", panelData.id);
995
1097
  resizeHandleElement.setAttribute("aria-valuemax", "" + Math.round(valueMax));
996
1098
  resizeHandleElement.setAttribute("aria-valuemin", "" + Math.round(valueMin));
@@ -1011,17 +1113,17 @@ function useWindowSplitterPanelGroupBehavior({
1011
1113
  return;
1012
1114
  }
1013
1115
  const eagerValues = eagerValuesRef.current;
1014
- assert(eagerValues);
1116
+ assert(eagerValues, `Eager values not found`);
1015
1117
  const {
1016
1118
  panelDataArray
1017
1119
  } = eagerValues;
1018
1120
  const groupElement = getPanelGroupElement(groupId, panelGroupElement);
1019
1121
  assert(groupElement != null, `No group found for id "${groupId}"`);
1020
1122
  const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
1021
- assert(handles);
1123
+ assert(handles, `No resize handles found for group id "${groupId}"`);
1022
1124
  const cleanupFunctions = handles.map(handle => {
1023
1125
  const handleId = handle.getAttribute("data-panel-resize-handle-id");
1024
- assert(handleId);
1126
+ assert(handleId, `Resize handle element has no handle id attribute`);
1025
1127
  const [idBefore, idAfter] = getResizeHandlePanelIds(groupId, handleId, panelDataArray, panelGroupElement);
1026
1128
  if (idBefore == null || idAfter == null) {
1027
1129
  return () => {};
@@ -1037,7 +1139,7 @@ function useWindowSplitterPanelGroupBehavior({
1037
1139
  const index = panelDataArray.findIndex(panelData => panelData.id === idBefore);
1038
1140
  if (index >= 0) {
1039
1141
  const panelData = panelDataArray[index];
1040
- assert(panelData);
1142
+ assert(panelData, `No panel data found for index ${index}`);
1041
1143
  const size = layout[index];
1042
1144
  const {
1043
1145
  collapsedSize = 0,
@@ -1096,15 +1198,15 @@ function getResizeEventCursorPosition(direction, event) {
1096
1198
  function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState, panelGroupElement) {
1097
1199
  const isHorizontal = direction === "horizontal";
1098
1200
  const handleElement = getResizeHandleElement(dragHandleId, panelGroupElement);
1099
- assert(handleElement);
1201
+ assert(handleElement, `No resize handle element found for id "${dragHandleId}"`);
1100
1202
  const groupId = handleElement.getAttribute("data-panel-group-id");
1101
- assert(groupId);
1203
+ assert(groupId, `Resize handle element has no group id attribute`);
1102
1204
  let {
1103
1205
  initialCursorPosition
1104
1206
  } = initialDragState;
1105
1207
  const cursorPosition = getResizeEventCursorPosition(direction, event);
1106
1208
  const groupElement = getPanelGroupElement(groupId, panelGroupElement);
1107
- assert(groupElement);
1209
+ assert(groupElement, `No group element found for id "${groupId}"`);
1108
1210
  const groupRect = groupElement.getBoundingClientRect();
1109
1211
  const groupSizeInPixels = isHorizontal ? groupRect.width : groupRect.height;
1110
1212
  const offsetPixels = cursorPosition - initialCursorPosition;
@@ -1165,7 +1267,7 @@ function calculateUnsafeDefaultLayout({
1165
1267
  // Distribute default sizes first
1166
1268
  for (let index = 0; index < panelDataArray.length; index++) {
1167
1269
  const panelConstraints = panelConstraintsArray[index];
1168
- assert(panelConstraints);
1270
+ assert(panelConstraints, `Panel constraints not found for index ${index}`);
1169
1271
  const {
1170
1272
  defaultSize
1171
1273
  } = panelConstraints;
@@ -1179,7 +1281,7 @@ function calculateUnsafeDefaultLayout({
1179
1281
  // Remaining size should be distributed evenly between panels without default sizes
1180
1282
  for (let index = 0; index < panelDataArray.length; index++) {
1181
1283
  const panelConstraints = panelConstraintsArray[index];
1182
- assert(panelConstraints);
1284
+ assert(panelConstraints, `Panel constraints not found for index ${index}`);
1183
1285
  const {
1184
1286
  defaultSize
1185
1287
  } = panelConstraints;
@@ -1199,7 +1301,7 @@ function calculateUnsafeDefaultLayout({
1199
1301
  function callPanelCallbacks(panelsArray, layout, panelIdToLastNotifiedSizeMap) {
1200
1302
  layout.forEach((size, index) => {
1201
1303
  const panelData = panelsArray[index];
1202
- assert(panelData);
1304
+ assert(panelData, `Panel data not found for index ${index}`);
1203
1305
  const {
1204
1306
  callbacks,
1205
1307
  constraints,
@@ -1383,7 +1485,7 @@ function validatePanelConstraints({
1383
1485
  {
1384
1486
  const warnings = [];
1385
1487
  const panelConstraints = panelConstraintsArray[panelIndex];
1386
- assert(panelConstraints);
1488
+ assert(panelConstraints, `No panel constraints found for index ${panelIndex}`);
1387
1489
  const {
1388
1490
  collapsedSize = 0,
1389
1491
  collapsible = false,
@@ -1437,7 +1539,7 @@ function validatePanelGroupLayout({
1437
1539
  }
1438
1540
  for (let index = 0; index < panelConstraints.length; index++) {
1439
1541
  const unsafeSize = nextLayout[index];
1440
- assert(unsafeSize != null);
1542
+ assert(unsafeSize != null, `No layout data found for index ${index}`);
1441
1543
  const safeSize = 100 / nextLayoutTotalSize * unsafeSize;
1442
1544
  nextLayout[index] = safeSize;
1443
1545
  }
@@ -1447,7 +1549,7 @@ function validatePanelGroupLayout({
1447
1549
  // First pass: Validate the proposed layout given each panel's constraints
1448
1550
  for (let index = 0; index < panelConstraints.length; index++) {
1449
1551
  const unsafeSize = nextLayout[index];
1450
- assert(unsafeSize != null);
1552
+ assert(unsafeSize != null, `No layout data found for index ${index}`);
1451
1553
  const safeSize = resizePanel({
1452
1554
  panelConstraints,
1453
1555
  panelIndex: index,
@@ -1464,7 +1566,7 @@ function validatePanelGroupLayout({
1464
1566
  if (!fuzzyNumbersEqual(remainingSize, 0)) {
1465
1567
  for (let index = 0; index < panelConstraints.length; index++) {
1466
1568
  const prevSize = nextLayout[index];
1467
- assert(prevSize != null);
1569
+ assert(prevSize != null, `No layout data found for index ${index}`);
1468
1570
  const unsafeSize = prevSize + remainingSize;
1469
1571
  const safeSize = resizePanel({
1470
1572
  panelConstraints,
@@ -1641,7 +1743,7 @@ function PanelGroupWithForwardedRef({
1641
1743
  const panelConstraints = panelDataArray.map(panelData => panelData.constraints);
1642
1744
  for (let panelIndex = 0; panelIndex < panelConstraints.length; panelIndex++) {
1643
1745
  const panelData = panelDataArray[panelIndex];
1644
- assert(panelData);
1746
+ assert(panelData, `Panel data not found for index ${panelIndex}`);
1645
1747
  const isValid = validatePanelConstraints({
1646
1748
  panelConstraints,
1647
1749
  panelId: panelData.id,
@@ -1672,7 +1774,7 @@ function PanelGroupWithForwardedRef({
1672
1774
  panelSize,
1673
1775
  pivotIndices
1674
1776
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1675
- assert(panelSize != null);
1777
+ assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1676
1778
  if (panelSize !== collapsedSize) {
1677
1779
  // Store size before collapse;
1678
1780
  // This is the size that gets restored if the expand() API is used.
@@ -1749,7 +1851,7 @@ function PanelGroupWithForwardedRef({
1749
1851
  const {
1750
1852
  panelSize
1751
1853
  } = panelDataHelper(panelDataArray, panelData, layout);
1752
- assert(panelSize != null);
1854
+ assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1753
1855
  return panelSize;
1754
1856
  }, []);
1755
1857
 
@@ -1793,7 +1895,7 @@ function PanelGroupWithForwardedRef({
1793
1895
  collapsible,
1794
1896
  panelSize
1795
1897
  } = panelDataHelper(panelDataArray, panelData, layout);
1796
- assert(panelSize != null);
1898
+ assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1797
1899
  return !collapsible || panelSize > collapsedSize;
1798
1900
  }, []);
1799
1901
  const registerPanel = useCallback(panelData => {
@@ -1960,7 +2062,7 @@ function PanelGroupWithForwardedRef({
1960
2062
  panelSize,
1961
2063
  pivotIndices
1962
2064
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1963
- assert(panelSize != null);
2065
+ assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1964
2066
  const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
1965
2067
  const delta = isLastPanel ? panelSize - unsafePanelSize : unsafePanelSize - panelSize;
1966
2068
  const nextLayout = adjustLayoutByDelta({
@@ -1997,7 +2099,10 @@ function PanelGroupWithForwardedRef({
1997
2099
  const {
1998
2100
  panelSize: prevPanelSize
1999
2101
  } = panelDataHelper(panelDataArray, panelData, layout);
2000
- assert(prevPanelSize != null);
2102
+ if (prevPanelSize == null) {
2103
+ // It's possible that the panels in this group have changed since the last render
2104
+ return;
2105
+ }
2001
2106
  if (prevCollapsible && nextCollapsible && prevPanelSize === prevCollapsedSize) {
2002
2107
  if (prevCollapsedSize !== nextCollapsedSize) {
2003
2108
  resizePanel(panelData, nextCollapsedSize);
@@ -2019,7 +2124,7 @@ function PanelGroupWithForwardedRef({
2019
2124
  return;
2020
2125
  }
2021
2126
  const handleElement = getResizeHandleElement(dragHandleId, panelGroupElementRef.current);
2022
- assert(handleElement);
2127
+ assert(handleElement, `Drag handle element not found for id "${dragHandleId}"`);
2023
2128
  const initialCursorPosition = getResizeEventCursorPosition(direction, event);
2024
2129
  setDragState({
2025
2130
  dragHandleId,
@@ -2148,10 +2253,10 @@ function useWindowSplitterResizeHandlerBehavior({
2148
2253
  {
2149
2254
  event.preventDefault();
2150
2255
  const groupId = handleElement.getAttribute("data-panel-group-id");
2151
- assert(groupId);
2256
+ assert(groupId, `No group element found for id "${groupId}"`);
2152
2257
  const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
2153
2258
  const index = getResizeHandleElementIndex(groupId, handleId, panelGroupElement);
2154
- assert(index !== null);
2259
+ assert(index !== null, `No resize element found for id "${handleId}"`);
2155
2260
  const nextIndex = event.shiftKey ? index > 0 ? index - 1 : handles.length - 1 : index + 1 < handles.length ? index + 1 : 0;
2156
2261
  const nextHandle = handles[nextIndex];
2157
2262
  nextHandle.focus();
@@ -2223,7 +2328,7 @@ function PanelResizeHandle({
2223
2328
  return;
2224
2329
  }
2225
2330
  const element = elementRef.current;
2226
- assert(element);
2331
+ assert(element, "Element ref not attached");
2227
2332
  const setResizeHandlerState = (action, isActive, event) => {
2228
2333
  if (isActive) {
2229
2334
  switch (action) {