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;
@@ -317,6 +316,114 @@ function intersects(rectOne, rectTwo, strict) {
317
316
  }
318
317
  }
319
318
 
319
+ // Forked from NPM stacking-order@2.0.0
320
+
321
+ /**
322
+ * Determine which of two nodes appears in front of the other —
323
+ * if `a` is in front, returns 1, otherwise returns -1
324
+ * @param {HTMLElement} a
325
+ * @param {HTMLElement} b
326
+ */
327
+ function compare(a, b) {
328
+ if (a === b) throw new Error("Cannot compare node with itself");
329
+ const ancestors = {
330
+ a: get_ancestors(a),
331
+ b: get_ancestors(b)
332
+ };
333
+ let common_ancestor;
334
+
335
+ // remove shared ancestors
336
+ while (ancestors.a.at(-1) === ancestors.b.at(-1)) {
337
+ a = ancestors.a.pop();
338
+ b = ancestors.b.pop();
339
+ common_ancestor = a;
340
+ }
341
+ assert(common_ancestor, "Stacking order can only be calculated for elements with a common ancestor");
342
+ const z_indexes = {
343
+ a: get_z_index(find_stacking_context(ancestors.a)),
344
+ b: get_z_index(find_stacking_context(ancestors.b))
345
+ };
346
+ if (z_indexes.a === z_indexes.b) {
347
+ const children = common_ancestor.childNodes;
348
+ const furthest_ancestors = {
349
+ a: ancestors.a.at(-1),
350
+ b: ancestors.b.at(-1)
351
+ };
352
+ let i = children.length;
353
+ while (i--) {
354
+ const child = children[i];
355
+ if (child === furthest_ancestors.a) return 1;
356
+ if (child === furthest_ancestors.b) return -1;
357
+ }
358
+ }
359
+ return Math.sign(z_indexes.a - z_indexes.b);
360
+ }
361
+ const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
362
+
363
+ /** @param {HTMLElement} node */
364
+ function is_flex_item(node) {
365
+ const display = getComputedStyle(get_parent(node)).display;
366
+ return display === "flex" || display === "inline-flex";
367
+ }
368
+
369
+ /** @param {HTMLElement} node */
370
+ function creates_stacking_context(node) {
371
+ const style = getComputedStyle(node);
372
+
373
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
374
+ if (style.position === "fixed") return true;
375
+ // Forked to fix upstream bug https://github.com/Rich-Harris/stacking-order/issues/3
376
+ // if (
377
+ // (style.zIndex !== "auto" && style.position !== "static") ||
378
+ // is_flex_item(node)
379
+ // )
380
+ if (style.zIndex !== "auto" && (style.position !== "static" || is_flex_item(node))) return true;
381
+ if (+style.opacity < 1) return true;
382
+ if ("transform" in style && style.transform !== "none") return true;
383
+ if ("webkitTransform" in style && style.webkitTransform !== "none") return true;
384
+ if ("mixBlendMode" in style && style.mixBlendMode !== "normal") return true;
385
+ if ("filter" in style && style.filter !== "none") return true;
386
+ if ("webkitFilter" in style && style.webkitFilter !== "none") return true;
387
+ if ("isolation" in style && style.isolation === "isolate") return true;
388
+ if (props.test(style.willChange)) return true;
389
+ // @ts-expect-error
390
+ if (style.webkitOverflowScrolling === "touch") return true;
391
+ return false;
392
+ }
393
+
394
+ /** @param {HTMLElement[]} nodes */
395
+ function find_stacking_context(nodes) {
396
+ let i = nodes.length;
397
+ while (i--) {
398
+ const node = nodes[i];
399
+ assert(node, "Missing node");
400
+ if (creates_stacking_context(node)) return node;
401
+ }
402
+ return null;
403
+ }
404
+
405
+ /** @param {HTMLElement} node */
406
+ function get_z_index(node) {
407
+ return node && Number(getComputedStyle(node).zIndex) || 0;
408
+ }
409
+
410
+ /** @param {HTMLElement} node */
411
+ function get_ancestors(node) {
412
+ const ancestors = [];
413
+ while (node) {
414
+ ancestors.push(node);
415
+ node = get_parent(node);
416
+ }
417
+ return ancestors; // [ node, ... <body>, <html>, document ]
418
+ }
419
+
420
+ /** @param {HTMLElement} node */
421
+ function get_parent(node) {
422
+ var _node$parentNode;
423
+ // @ts-ignore
424
+ return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
425
+ }
426
+
320
427
  const EXCEEDED_HORIZONTAL_MIN = 0b0001;
321
428
  const EXCEEDED_HORIZONTAL_MAX = 0b0010;
322
429
  const EXCEEDED_VERTICAL_MIN = 0b0100;
@@ -458,7 +565,7 @@ function recalculateIntersectingHandles({
458
565
  // Calculating stacking order has a cost, so we should avoid it if possible
459
566
  // That is why we only check potentially intersecting handles,
460
567
  // and why we skip if the event target is within the handle's DOM
461
- stackingOrder.compare(targetElement, dragHandleElement) > 0) {
568
+ compare(targetElement, dragHandleElement) > 0) {
462
569
  // If the target is above the drag handle, then we also need to confirm they overlap
463
570
  // If they are beside each other (e.g. a panel and its drag handle) then the handle is still interactive
464
571
  //
@@ -529,7 +636,7 @@ function updateListeners() {
529
636
  window.removeEventListener("mouseup", handlePointerUp);
530
637
  window.removeEventListener("touchcancel", handlePointerUp);
531
638
  window.removeEventListener("touchend", handlePointerUp);
532
- if (registerResizeHandle.length > 0) {
639
+ if (registeredResizeHandlers.size > 0) {
533
640
  if (isPointerDown) {
534
641
  if (intersectingHandles.length > 0) {
535
642
  ownerDocumentCounts.forEach((count, ownerDocument) => {
@@ -576,7 +683,7 @@ function updateResizeHandlerStates(action, event) {
576
683
  });
577
684
  }
578
685
 
579
- function assert(expectedCondition, message = "Assertion failed!") {
686
+ function assert(expectedCondition, message) {
580
687
  if (!expectedCondition) {
581
688
  console.error(message);
582
689
  throw Error(message);
@@ -607,7 +714,7 @@ function resizePanel({
607
714
  size
608
715
  }) {
609
716
  const panelConstraints = panelConstraintsArray[panelIndex];
610
- assert(panelConstraints != null);
717
+ assert(panelConstraints != null, `Panel constraints not found for index ${panelIndex}`);
611
718
  let {
612
719
  collapsedSize = 0,
613
720
  collapsible,
@@ -645,8 +752,8 @@ function adjustLayoutByDelta({
645
752
  }
646
753
  const nextLayout = [...prevLayout];
647
754
  const [firstPivotIndex, secondPivotIndex] = pivotIndices;
648
- assert(firstPivotIndex != null);
649
- assert(secondPivotIndex != null);
755
+ assert(firstPivotIndex != null, "Invalid first pivot index");
756
+ assert(secondPivotIndex != null, "Invalid second pivot index");
650
757
  let deltaApplied = 0;
651
758
 
652
759
  //const DEBUG = [];
@@ -672,19 +779,18 @@ function adjustLayoutByDelta({
672
779
  // Check if we should expand a collapsed panel
673
780
  const index = delta < 0 ? secondPivotIndex : firstPivotIndex;
674
781
  const panelConstraints = panelConstraintsArray[index];
675
- assert(panelConstraints);
782
+ assert(panelConstraints, `Panel constraints not found for index ${index}`);
783
+ const {
784
+ collapsedSize = 0,
785
+ collapsible,
786
+ minSize = 0
787
+ } = panelConstraints;
676
788
 
677
789
  //DEBUG.push(`edge case check 1: ${index}`);
678
790
  //DEBUG.push(` -> collapsible? ${constraints.collapsible}`);
679
- if (panelConstraints.collapsible) {
791
+ if (collapsible) {
680
792
  const prevSize = prevLayout[index];
681
- assert(prevSize != null);
682
- const panelConstraints = panelConstraintsArray[index];
683
- assert(panelConstraints);
684
- const {
685
- collapsedSize = 0,
686
- minSize = 0
687
- } = panelConstraints;
793
+ assert(prevSize != null, `Previous layout not found for panel index ${index}`);
688
794
  if (fuzzyNumbersEqual(prevSize, collapsedSize)) {
689
795
  const localDelta = minSize - prevSize;
690
796
  //DEBUG.push(` -> expand delta: ${localDelta}`);
@@ -701,22 +807,18 @@ function adjustLayoutByDelta({
701
807
  // Check if we should collapse a panel at its minimum size
702
808
  const index = delta < 0 ? firstPivotIndex : secondPivotIndex;
703
809
  const panelConstraints = panelConstraintsArray[index];
704
- assert(panelConstraints);
810
+ assert(panelConstraints, `No panel constraints found for index ${index}`);
705
811
  const {
706
- collapsible
812
+ collapsedSize = 0,
813
+ collapsible,
814
+ minSize = 0
707
815
  } = panelConstraints;
708
816
 
709
817
  //DEBUG.push(`edge case check 2: ${index}`);
710
818
  //DEBUG.push(` -> collapsible? ${collapsible}`);
711
819
  if (collapsible) {
712
820
  const prevSize = prevLayout[index];
713
- assert(prevSize != null);
714
- const panelConstraints = panelConstraintsArray[index];
715
- assert(panelConstraints);
716
- const {
717
- collapsedSize = 0,
718
- minSize = 0
719
- } = panelConstraints;
821
+ assert(prevSize != null, `Previous layout not found for panel index ${index}`);
720
822
  if (fuzzyNumbersEqual(prevSize, minSize)) {
721
823
  const localDelta = prevSize - collapsedSize;
722
824
  //DEBUG.push(` -> expand delta: ${localDelta}`);
@@ -746,7 +848,7 @@ function adjustLayoutByDelta({
746
848
  //DEBUG.push("pre calc...");
747
849
  while (true) {
748
850
  const prevSize = prevLayout[index];
749
- assert(prevSize != null);
851
+ assert(prevSize != null, `Previous layout not found for panel index ${index}`);
750
852
  const maxSafeSize = resizePanel({
751
853
  panelConstraints: panelConstraintsArray,
752
854
  panelIndex: index,
@@ -777,7 +879,7 @@ function adjustLayoutByDelta({
777
879
  while (index >= 0 && index < panelConstraintsArray.length) {
778
880
  const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
779
881
  const prevSize = prevLayout[index];
780
- assert(prevSize != null);
882
+ assert(prevSize != null, `Previous layout not found for panel index ${index}`);
781
883
  const unsafeSize = prevSize - deltaRemaining;
782
884
  const safeSize = resizePanel({
783
885
  panelConstraints: panelConstraintsArray,
@@ -814,7 +916,7 @@ function adjustLayoutByDelta({
814
916
  // Now distribute the applied delta to the panels in the other direction
815
917
  const pivotIndex = delta < 0 ? secondPivotIndex : firstPivotIndex;
816
918
  const prevSize = prevLayout[pivotIndex];
817
- assert(prevSize != null);
919
+ assert(prevSize != null, `Previous layout not found for panel index ${pivotIndex}`);
818
920
  const unsafeSize = prevSize + deltaApplied;
819
921
  const safeSize = resizePanel({
820
922
  panelConstraints: panelConstraintsArray,
@@ -832,7 +934,7 @@ function adjustLayoutByDelta({
832
934
  let index = pivotIndex;
833
935
  while (index >= 0 && index < panelConstraintsArray.length) {
834
936
  const prevSize = nextLayout[index];
835
- assert(prevSize != null);
937
+ assert(prevSize != null, `Previous layout not found for panel index ${index}`);
836
938
  const unsafeSize = prevSize + deltaRemaining;
837
939
  const safeSize = resizePanel({
838
940
  panelConstraints: panelConstraintsArray,
@@ -878,7 +980,7 @@ function calculateAriaValues({
878
980
  let totalMinSize = 0;
879
981
  let totalMaxSize = 0;
880
982
  const firstIndex = pivotIndices[0];
881
- assert(firstIndex != null);
983
+ assert(firstIndex != null, "No pivot index found");
882
984
 
883
985
  // A panel's effective min/max sizes also need to account for other panel's sizes.
884
986
  panelsArray.forEach((panelData, index) => {
@@ -997,7 +1099,7 @@ function useWindowSplitterPanelGroupBehavior({
997
1099
  }
998
1100
  } else {
999
1101
  const panelData = panelDataArray[index];
1000
- assert(panelData);
1102
+ assert(panelData, `No panel data found for index "${index}"`);
1001
1103
  resizeHandleElement.setAttribute("aria-controls", panelData.id);
1002
1104
  resizeHandleElement.setAttribute("aria-valuemax", "" + Math.round(valueMax));
1003
1105
  resizeHandleElement.setAttribute("aria-valuemin", "" + Math.round(valueMin));
@@ -1018,17 +1120,17 @@ function useWindowSplitterPanelGroupBehavior({
1018
1120
  return;
1019
1121
  }
1020
1122
  const eagerValues = eagerValuesRef.current;
1021
- assert(eagerValues);
1123
+ assert(eagerValues, `Eager values not found`);
1022
1124
  const {
1023
1125
  panelDataArray
1024
1126
  } = eagerValues;
1025
1127
  const groupElement = getPanelGroupElement(groupId, panelGroupElement);
1026
1128
  assert(groupElement != null, `No group found for id "${groupId}"`);
1027
1129
  const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
1028
- assert(handles);
1130
+ assert(handles, `No resize handles found for group id "${groupId}"`);
1029
1131
  const cleanupFunctions = handles.map(handle => {
1030
1132
  const handleId = handle.getAttribute("data-panel-resize-handle-id");
1031
- assert(handleId);
1133
+ assert(handleId, `Resize handle element has no handle id attribute`);
1032
1134
  const [idBefore, idAfter] = getResizeHandlePanelIds(groupId, handleId, panelDataArray, panelGroupElement);
1033
1135
  if (idBefore == null || idAfter == null) {
1034
1136
  return () => {};
@@ -1044,7 +1146,7 @@ function useWindowSplitterPanelGroupBehavior({
1044
1146
  const index = panelDataArray.findIndex(panelData => panelData.id === idBefore);
1045
1147
  if (index >= 0) {
1046
1148
  const panelData = panelDataArray[index];
1047
- assert(panelData);
1149
+ assert(panelData, `No panel data found for index ${index}`);
1048
1150
  const size = layout[index];
1049
1151
  const {
1050
1152
  collapsedSize = 0,
@@ -1103,15 +1205,15 @@ function getResizeEventCursorPosition(direction, event) {
1103
1205
  function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState, panelGroupElement) {
1104
1206
  const isHorizontal = direction === "horizontal";
1105
1207
  const handleElement = getResizeHandleElement(dragHandleId, panelGroupElement);
1106
- assert(handleElement);
1208
+ assert(handleElement, `No resize handle element found for id "${dragHandleId}"`);
1107
1209
  const groupId = handleElement.getAttribute("data-panel-group-id");
1108
- assert(groupId);
1210
+ assert(groupId, `Resize handle element has no group id attribute`);
1109
1211
  let {
1110
1212
  initialCursorPosition
1111
1213
  } = initialDragState;
1112
1214
  const cursorPosition = getResizeEventCursorPosition(direction, event);
1113
1215
  const groupElement = getPanelGroupElement(groupId, panelGroupElement);
1114
- assert(groupElement);
1216
+ assert(groupElement, `No group element found for id "${groupId}"`);
1115
1217
  const groupRect = groupElement.getBoundingClientRect();
1116
1218
  const groupSizeInPixels = isHorizontal ? groupRect.width : groupRect.height;
1117
1219
  const offsetPixels = cursorPosition - initialCursorPosition;
@@ -1172,7 +1274,7 @@ function calculateUnsafeDefaultLayout({
1172
1274
  // Distribute default sizes first
1173
1275
  for (let index = 0; index < panelDataArray.length; index++) {
1174
1276
  const panelConstraints = panelConstraintsArray[index];
1175
- assert(panelConstraints);
1277
+ assert(panelConstraints, `Panel constraints not found for index ${index}`);
1176
1278
  const {
1177
1279
  defaultSize
1178
1280
  } = panelConstraints;
@@ -1186,7 +1288,7 @@ function calculateUnsafeDefaultLayout({
1186
1288
  // Remaining size should be distributed evenly between panels without default sizes
1187
1289
  for (let index = 0; index < panelDataArray.length; index++) {
1188
1290
  const panelConstraints = panelConstraintsArray[index];
1189
- assert(panelConstraints);
1291
+ assert(panelConstraints, `Panel constraints not found for index ${index}`);
1190
1292
  const {
1191
1293
  defaultSize
1192
1294
  } = panelConstraints;
@@ -1206,7 +1308,7 @@ function calculateUnsafeDefaultLayout({
1206
1308
  function callPanelCallbacks(panelsArray, layout, panelIdToLastNotifiedSizeMap) {
1207
1309
  layout.forEach((size, index) => {
1208
1310
  const panelData = panelsArray[index];
1209
- assert(panelData);
1311
+ assert(panelData, `Panel data not found for index ${index}`);
1210
1312
  const {
1211
1313
  callbacks,
1212
1314
  constraints,
@@ -1390,7 +1492,7 @@ function validatePanelConstraints({
1390
1492
  {
1391
1493
  const warnings = [];
1392
1494
  const panelConstraints = panelConstraintsArray[panelIndex];
1393
- assert(panelConstraints);
1495
+ assert(panelConstraints, `No panel constraints found for index ${panelIndex}`);
1394
1496
  const {
1395
1497
  collapsedSize = 0,
1396
1498
  collapsible = false,
@@ -1444,7 +1546,7 @@ function validatePanelGroupLayout({
1444
1546
  }
1445
1547
  for (let index = 0; index < panelConstraints.length; index++) {
1446
1548
  const unsafeSize = nextLayout[index];
1447
- assert(unsafeSize != null);
1549
+ assert(unsafeSize != null, `No layout data found for index ${index}`);
1448
1550
  const safeSize = 100 / nextLayoutTotalSize * unsafeSize;
1449
1551
  nextLayout[index] = safeSize;
1450
1552
  }
@@ -1454,7 +1556,7 @@ function validatePanelGroupLayout({
1454
1556
  // First pass: Validate the proposed layout given each panel's constraints
1455
1557
  for (let index = 0; index < panelConstraints.length; index++) {
1456
1558
  const unsafeSize = nextLayout[index];
1457
- assert(unsafeSize != null);
1559
+ assert(unsafeSize != null, `No layout data found for index ${index}`);
1458
1560
  const safeSize = resizePanel({
1459
1561
  panelConstraints,
1460
1562
  panelIndex: index,
@@ -1471,7 +1573,7 @@ function validatePanelGroupLayout({
1471
1573
  if (!fuzzyNumbersEqual(remainingSize, 0)) {
1472
1574
  for (let index = 0; index < panelConstraints.length; index++) {
1473
1575
  const prevSize = nextLayout[index];
1474
- assert(prevSize != null);
1576
+ assert(prevSize != null, `No layout data found for index ${index}`);
1475
1577
  const unsafeSize = prevSize + remainingSize;
1476
1578
  const safeSize = resizePanel({
1477
1579
  panelConstraints,
@@ -1648,7 +1750,7 @@ function PanelGroupWithForwardedRef({
1648
1750
  const panelConstraints = panelDataArray.map(panelData => panelData.constraints);
1649
1751
  for (let panelIndex = 0; panelIndex < panelConstraints.length; panelIndex++) {
1650
1752
  const panelData = panelDataArray[panelIndex];
1651
- assert(panelData);
1753
+ assert(panelData, `Panel data not found for index ${panelIndex}`);
1652
1754
  const isValid = validatePanelConstraints({
1653
1755
  panelConstraints,
1654
1756
  panelId: panelData.id,
@@ -1679,7 +1781,7 @@ function PanelGroupWithForwardedRef({
1679
1781
  panelSize,
1680
1782
  pivotIndices
1681
1783
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1682
- assert(panelSize != null);
1784
+ assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1683
1785
  if (panelSize !== collapsedSize) {
1684
1786
  // Store size before collapse;
1685
1787
  // This is the size that gets restored if the expand() API is used.
@@ -1756,7 +1858,7 @@ function PanelGroupWithForwardedRef({
1756
1858
  const {
1757
1859
  panelSize
1758
1860
  } = panelDataHelper(panelDataArray, panelData, layout);
1759
- assert(panelSize != null);
1861
+ assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1760
1862
  return panelSize;
1761
1863
  }, []);
1762
1864
 
@@ -1800,7 +1902,7 @@ function PanelGroupWithForwardedRef({
1800
1902
  collapsible,
1801
1903
  panelSize
1802
1904
  } = panelDataHelper(panelDataArray, panelData, layout);
1803
- assert(panelSize != null);
1905
+ assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1804
1906
  return !collapsible || panelSize > collapsedSize;
1805
1907
  }, []);
1806
1908
  const registerPanel = useCallback(panelData => {
@@ -1967,7 +2069,7 @@ function PanelGroupWithForwardedRef({
1967
2069
  panelSize,
1968
2070
  pivotIndices
1969
2071
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1970
- assert(panelSize != null);
2072
+ assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1971
2073
  const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
1972
2074
  const delta = isLastPanel ? panelSize - unsafePanelSize : unsafePanelSize - panelSize;
1973
2075
  const nextLayout = adjustLayoutByDelta({
@@ -2004,7 +2106,10 @@ function PanelGroupWithForwardedRef({
2004
2106
  const {
2005
2107
  panelSize: prevPanelSize
2006
2108
  } = panelDataHelper(panelDataArray, panelData, layout);
2007
- assert(prevPanelSize != null);
2109
+ if (prevPanelSize == null) {
2110
+ // It's possible that the panels in this group have changed since the last render
2111
+ return;
2112
+ }
2008
2113
  if (prevCollapsible && nextCollapsible && prevPanelSize === prevCollapsedSize) {
2009
2114
  if (prevCollapsedSize !== nextCollapsedSize) {
2010
2115
  resizePanel(panelData, nextCollapsedSize);
@@ -2026,7 +2131,7 @@ function PanelGroupWithForwardedRef({
2026
2131
  return;
2027
2132
  }
2028
2133
  const handleElement = getResizeHandleElement(dragHandleId, panelGroupElementRef.current);
2029
- assert(handleElement);
2134
+ assert(handleElement, `Drag handle element not found for id "${dragHandleId}"`);
2030
2135
  const initialCursorPosition = getResizeEventCursorPosition(direction, event);
2031
2136
  setDragState({
2032
2137
  dragHandleId,
@@ -2155,10 +2260,10 @@ function useWindowSplitterResizeHandlerBehavior({
2155
2260
  {
2156
2261
  event.preventDefault();
2157
2262
  const groupId = handleElement.getAttribute("data-panel-group-id");
2158
- assert(groupId);
2263
+ assert(groupId, `No group element found for id "${groupId}"`);
2159
2264
  const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
2160
2265
  const index = getResizeHandleElementIndex(groupId, handleId, panelGroupElement);
2161
- assert(index !== null);
2266
+ assert(index !== null, `No resize element found for id "${handleId}"`);
2162
2267
  const nextIndex = event.shiftKey ? index > 0 ? index - 1 : handles.length - 1 : index + 1 < handles.length ? index + 1 : 0;
2163
2268
  const nextHandle = handles[nextIndex];
2164
2269
  nextHandle.focus();
@@ -2230,7 +2335,7 @@ function PanelResizeHandle({
2230
2335
  return;
2231
2336
  }
2232
2337
  const element = elementRef.current;
2233
- assert(element);
2338
+ assert(element, "Element ref not attached");
2234
2339
  const setResizeHandlerState = (action, isActive, event) => {
2235
2340
  if (isActive) {
2236
2341
  switch (action) {