react-resizable-panels 2.0.14 → 2.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/react-resizable-panels.browser.cjs.js +5 -5
- package/dist/react-resizable-panels.browser.development.cjs.js +5 -5
- package/dist/react-resizable-panels.browser.development.esm.js +5 -5
- package/dist/react-resizable-panels.browser.esm.js +5 -5
- package/dist/react-resizable-panels.cjs.js +5 -5
- package/dist/react-resizable-panels.development.cjs.js +5 -5
- package/dist/react-resizable-panels.development.esm.js +5 -5
- package/dist/react-resizable-panels.development.node.cjs.js +5 -5
- package/dist/react-resizable-panels.development.node.esm.js +5 -5
- package/dist/react-resizable-panels.esm.js +5 -5
- package/dist/react-resizable-panels.node.cjs.js +5 -5
- package/dist/react-resizable-panels.node.esm.js +5 -5
- package/package.json +1 -1
- package/src/Panel.test.tsx +104 -0
- package/src/utils/adjustLayoutByDelta.ts +2 -2
- package/src/utils/callPanelCallbacks.ts +7 -4
- package/src/utils/computePanelFlexBoxStyle.ts +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.0.16
|
|
4
|
+
|
|
5
|
+
- Replaced `.toPrecision()` with `.toFixed()` to avoid undesirable layout shift (#323)
|
|
6
|
+
|
|
7
|
+
## 2.0.15
|
|
8
|
+
|
|
9
|
+
- Better account for high-precision sizes with `onCollapse` and `onExpand` callbacks (#325)
|
|
10
|
+
|
|
3
11
|
## 2.0.14
|
|
4
12
|
|
|
5
13
|
- Better account for high-precision `collapsedSize` values (#325)
|
|
@@ -900,7 +900,7 @@ function adjustLayoutByDelta({
|
|
|
900
900
|
if (!fuzzyNumbersEqual(prevSize, safeSize)) {
|
|
901
901
|
deltaApplied += prevSize - safeSize;
|
|
902
902
|
nextLayout[index] = safeSize;
|
|
903
|
-
if (deltaApplied.
|
|
903
|
+
if (deltaApplied.toFixed(3).localeCompare(Math.abs(delta).toFixed(3), undefined, {
|
|
904
904
|
numeric: true
|
|
905
905
|
}) >= 0) {
|
|
906
906
|
break;
|
|
@@ -1340,10 +1340,10 @@ function callPanelCallbacks(panelsArray, layout, panelIdToLastNotifiedSizeMap) {
|
|
|
1340
1340
|
onResize(size, lastNotifiedSize);
|
|
1341
1341
|
}
|
|
1342
1342
|
if (collapsible && (onCollapse || onExpand)) {
|
|
1343
|
-
if (onExpand && (lastNotifiedSize == null || lastNotifiedSize
|
|
1343
|
+
if (onExpand && (lastNotifiedSize == null || fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && !fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
1344
1344
|
onExpand();
|
|
1345
1345
|
}
|
|
1346
|
-
if (onCollapse && (lastNotifiedSize == null || lastNotifiedSize
|
|
1346
|
+
if (onCollapse && (lastNotifiedSize == null || !fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
1347
1347
|
onCollapse();
|
|
1348
1348
|
}
|
|
1349
1349
|
}
|
|
@@ -1380,12 +1380,12 @@ function computePanelFlexBoxStyle({
|
|
|
1380
1380
|
if (size == null) {
|
|
1381
1381
|
// Initial render (before panels have registered themselves)
|
|
1382
1382
|
// In order to support server rendering, fall back to default size if provided
|
|
1383
|
-
flexGrow = defaultSize != undefined ? defaultSize.
|
|
1383
|
+
flexGrow = defaultSize != undefined ? defaultSize.toFixed(precision) : "1";
|
|
1384
1384
|
} else if (panelData.length === 1) {
|
|
1385
1385
|
// Special case: Single panel group should always fill full width/height
|
|
1386
1386
|
flexGrow = "1";
|
|
1387
1387
|
} else {
|
|
1388
|
-
flexGrow = size.
|
|
1388
|
+
flexGrow = size.toFixed(precision);
|
|
1389
1389
|
}
|
|
1390
1390
|
return {
|
|
1391
1391
|
flexBasis: 0,
|
|
@@ -906,7 +906,7 @@ function adjustLayoutByDelta({
|
|
|
906
906
|
if (!fuzzyNumbersEqual(prevSize, safeSize)) {
|
|
907
907
|
deltaApplied += prevSize - safeSize;
|
|
908
908
|
nextLayout[index] = safeSize;
|
|
909
|
-
if (deltaApplied.
|
|
909
|
+
if (deltaApplied.toFixed(3).localeCompare(Math.abs(delta).toFixed(3), undefined, {
|
|
910
910
|
numeric: true
|
|
911
911
|
}) >= 0) {
|
|
912
912
|
break;
|
|
@@ -1356,10 +1356,10 @@ function callPanelCallbacks(panelsArray, layout, panelIdToLastNotifiedSizeMap) {
|
|
|
1356
1356
|
onResize(size, lastNotifiedSize);
|
|
1357
1357
|
}
|
|
1358
1358
|
if (collapsible && (onCollapse || onExpand)) {
|
|
1359
|
-
if (onExpand && (lastNotifiedSize == null || lastNotifiedSize
|
|
1359
|
+
if (onExpand && (lastNotifiedSize == null || fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && !fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
1360
1360
|
onExpand();
|
|
1361
1361
|
}
|
|
1362
|
-
if (onCollapse && (lastNotifiedSize == null || lastNotifiedSize
|
|
1362
|
+
if (onCollapse && (lastNotifiedSize == null || !fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
1363
1363
|
onCollapse();
|
|
1364
1364
|
}
|
|
1365
1365
|
}
|
|
@@ -1396,12 +1396,12 @@ function computePanelFlexBoxStyle({
|
|
|
1396
1396
|
if (size == null) {
|
|
1397
1397
|
// Initial render (before panels have registered themselves)
|
|
1398
1398
|
// In order to support server rendering, fall back to default size if provided
|
|
1399
|
-
flexGrow = defaultSize != undefined ? defaultSize.
|
|
1399
|
+
flexGrow = defaultSize != undefined ? defaultSize.toFixed(precision) : "1";
|
|
1400
1400
|
} else if (panelData.length === 1) {
|
|
1401
1401
|
// Special case: Single panel group should always fill full width/height
|
|
1402
1402
|
flexGrow = "1";
|
|
1403
1403
|
} else {
|
|
1404
|
-
flexGrow = size.
|
|
1404
|
+
flexGrow = size.toFixed(precision);
|
|
1405
1405
|
}
|
|
1406
1406
|
return {
|
|
1407
1407
|
flexBasis: 0,
|
|
@@ -882,7 +882,7 @@ function adjustLayoutByDelta({
|
|
|
882
882
|
if (!fuzzyNumbersEqual(prevSize, safeSize)) {
|
|
883
883
|
deltaApplied += prevSize - safeSize;
|
|
884
884
|
nextLayout[index] = safeSize;
|
|
885
|
-
if (deltaApplied.
|
|
885
|
+
if (deltaApplied.toFixed(3).localeCompare(Math.abs(delta).toFixed(3), undefined, {
|
|
886
886
|
numeric: true
|
|
887
887
|
}) >= 0) {
|
|
888
888
|
break;
|
|
@@ -1332,10 +1332,10 @@ function callPanelCallbacks(panelsArray, layout, panelIdToLastNotifiedSizeMap) {
|
|
|
1332
1332
|
onResize(size, lastNotifiedSize);
|
|
1333
1333
|
}
|
|
1334
1334
|
if (collapsible && (onCollapse || onExpand)) {
|
|
1335
|
-
if (onExpand && (lastNotifiedSize == null || lastNotifiedSize
|
|
1335
|
+
if (onExpand && (lastNotifiedSize == null || fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && !fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
1336
1336
|
onExpand();
|
|
1337
1337
|
}
|
|
1338
|
-
if (onCollapse && (lastNotifiedSize == null || lastNotifiedSize
|
|
1338
|
+
if (onCollapse && (lastNotifiedSize == null || !fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
1339
1339
|
onCollapse();
|
|
1340
1340
|
}
|
|
1341
1341
|
}
|
|
@@ -1372,12 +1372,12 @@ function computePanelFlexBoxStyle({
|
|
|
1372
1372
|
if (size == null) {
|
|
1373
1373
|
// Initial render (before panels have registered themselves)
|
|
1374
1374
|
// In order to support server rendering, fall back to default size if provided
|
|
1375
|
-
flexGrow = defaultSize != undefined ? defaultSize.
|
|
1375
|
+
flexGrow = defaultSize != undefined ? defaultSize.toFixed(precision) : "1";
|
|
1376
1376
|
} else if (panelData.length === 1) {
|
|
1377
1377
|
// Special case: Single panel group should always fill full width/height
|
|
1378
1378
|
flexGrow = "1";
|
|
1379
1379
|
} else {
|
|
1380
|
-
flexGrow = size.
|
|
1380
|
+
flexGrow = size.toFixed(precision);
|
|
1381
1381
|
}
|
|
1382
1382
|
return {
|
|
1383
1383
|
flexBasis: 0,
|
|
@@ -876,7 +876,7 @@ function adjustLayoutByDelta({
|
|
|
876
876
|
if (!fuzzyNumbersEqual(prevSize, safeSize)) {
|
|
877
877
|
deltaApplied += prevSize - safeSize;
|
|
878
878
|
nextLayout[index] = safeSize;
|
|
879
|
-
if (deltaApplied.
|
|
879
|
+
if (deltaApplied.toFixed(3).localeCompare(Math.abs(delta).toFixed(3), undefined, {
|
|
880
880
|
numeric: true
|
|
881
881
|
}) >= 0) {
|
|
882
882
|
break;
|
|
@@ -1316,10 +1316,10 @@ function callPanelCallbacks(panelsArray, layout, panelIdToLastNotifiedSizeMap) {
|
|
|
1316
1316
|
onResize(size, lastNotifiedSize);
|
|
1317
1317
|
}
|
|
1318
1318
|
if (collapsible && (onCollapse || onExpand)) {
|
|
1319
|
-
if (onExpand && (lastNotifiedSize == null || lastNotifiedSize
|
|
1319
|
+
if (onExpand && (lastNotifiedSize == null || fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && !fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
1320
1320
|
onExpand();
|
|
1321
1321
|
}
|
|
1322
|
-
if (onCollapse && (lastNotifiedSize == null || lastNotifiedSize
|
|
1322
|
+
if (onCollapse && (lastNotifiedSize == null || !fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
1323
1323
|
onCollapse();
|
|
1324
1324
|
}
|
|
1325
1325
|
}
|
|
@@ -1356,12 +1356,12 @@ function computePanelFlexBoxStyle({
|
|
|
1356
1356
|
if (size == null) {
|
|
1357
1357
|
// Initial render (before panels have registered themselves)
|
|
1358
1358
|
// In order to support server rendering, fall back to default size if provided
|
|
1359
|
-
flexGrow = defaultSize != undefined ? defaultSize.
|
|
1359
|
+
flexGrow = defaultSize != undefined ? defaultSize.toFixed(precision) : "1";
|
|
1360
1360
|
} else if (panelData.length === 1) {
|
|
1361
1361
|
// Special case: Single panel group should always fill full width/height
|
|
1362
1362
|
flexGrow = "1";
|
|
1363
1363
|
} else {
|
|
1364
|
-
flexGrow = size.
|
|
1364
|
+
flexGrow = size.toFixed(precision);
|
|
1365
1365
|
}
|
|
1366
1366
|
return {
|
|
1367
1367
|
flexBasis: 0,
|
|
@@ -902,7 +902,7 @@ function adjustLayoutByDelta({
|
|
|
902
902
|
if (!fuzzyNumbersEqual(prevSize, safeSize)) {
|
|
903
903
|
deltaApplied += prevSize - safeSize;
|
|
904
904
|
nextLayout[index] = safeSize;
|
|
905
|
-
if (deltaApplied.
|
|
905
|
+
if (deltaApplied.toFixed(3).localeCompare(Math.abs(delta).toFixed(3), undefined, {
|
|
906
906
|
numeric: true
|
|
907
907
|
}) >= 0) {
|
|
908
908
|
break;
|
|
@@ -1342,10 +1342,10 @@ function callPanelCallbacks(panelsArray, layout, panelIdToLastNotifiedSizeMap) {
|
|
|
1342
1342
|
onResize(size, lastNotifiedSize);
|
|
1343
1343
|
}
|
|
1344
1344
|
if (collapsible && (onCollapse || onExpand)) {
|
|
1345
|
-
if (onExpand && (lastNotifiedSize == null || lastNotifiedSize
|
|
1345
|
+
if (onExpand && (lastNotifiedSize == null || fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && !fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
1346
1346
|
onExpand();
|
|
1347
1347
|
}
|
|
1348
|
-
if (onCollapse && (lastNotifiedSize == null || lastNotifiedSize
|
|
1348
|
+
if (onCollapse && (lastNotifiedSize == null || !fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
1349
1349
|
onCollapse();
|
|
1350
1350
|
}
|
|
1351
1351
|
}
|
|
@@ -1382,12 +1382,12 @@ function computePanelFlexBoxStyle({
|
|
|
1382
1382
|
if (size == null) {
|
|
1383
1383
|
// Initial render (before panels have registered themselves)
|
|
1384
1384
|
// In order to support server rendering, fall back to default size if provided
|
|
1385
|
-
flexGrow = defaultSize != undefined ? defaultSize.
|
|
1385
|
+
flexGrow = defaultSize != undefined ? defaultSize.toFixed(precision) : "1";
|
|
1386
1386
|
} else if (panelData.length === 1) {
|
|
1387
1387
|
// Special case: Single panel group should always fill full width/height
|
|
1388
1388
|
flexGrow = "1";
|
|
1389
1389
|
} else {
|
|
1390
|
-
flexGrow = size.
|
|
1390
|
+
flexGrow = size.toFixed(precision);
|
|
1391
1391
|
}
|
|
1392
1392
|
return {
|
|
1393
1393
|
flexBasis: 0,
|
|
@@ -913,7 +913,7 @@ function adjustLayoutByDelta({
|
|
|
913
913
|
if (!fuzzyNumbersEqual(prevSize, safeSize)) {
|
|
914
914
|
deltaApplied += prevSize - safeSize;
|
|
915
915
|
nextLayout[index] = safeSize;
|
|
916
|
-
if (deltaApplied.
|
|
916
|
+
if (deltaApplied.toFixed(3).localeCompare(Math.abs(delta).toFixed(3), undefined, {
|
|
917
917
|
numeric: true
|
|
918
918
|
}) >= 0) {
|
|
919
919
|
break;
|
|
@@ -1363,10 +1363,10 @@ function callPanelCallbacks(panelsArray, layout, panelIdToLastNotifiedSizeMap) {
|
|
|
1363
1363
|
onResize(size, lastNotifiedSize);
|
|
1364
1364
|
}
|
|
1365
1365
|
if (collapsible && (onCollapse || onExpand)) {
|
|
1366
|
-
if (onExpand && (lastNotifiedSize == null || lastNotifiedSize
|
|
1366
|
+
if (onExpand && (lastNotifiedSize == null || fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && !fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
1367
1367
|
onExpand();
|
|
1368
1368
|
}
|
|
1369
|
-
if (onCollapse && (lastNotifiedSize == null || lastNotifiedSize
|
|
1369
|
+
if (onCollapse && (lastNotifiedSize == null || !fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
1370
1370
|
onCollapse();
|
|
1371
1371
|
}
|
|
1372
1372
|
}
|
|
@@ -1403,12 +1403,12 @@ function computePanelFlexBoxStyle({
|
|
|
1403
1403
|
if (size == null) {
|
|
1404
1404
|
// Initial render (before panels have registered themselves)
|
|
1405
1405
|
// In order to support server rendering, fall back to default size if provided
|
|
1406
|
-
flexGrow = defaultSize != undefined ? defaultSize.
|
|
1406
|
+
flexGrow = defaultSize != undefined ? defaultSize.toFixed(precision) : "1";
|
|
1407
1407
|
} else if (panelData.length === 1) {
|
|
1408
1408
|
// Special case: Single panel group should always fill full width/height
|
|
1409
1409
|
flexGrow = "1";
|
|
1410
1410
|
} else {
|
|
1411
|
-
flexGrow = size.
|
|
1411
|
+
flexGrow = size.toFixed(precision);
|
|
1412
1412
|
}
|
|
1413
1413
|
return {
|
|
1414
1414
|
flexBasis: 0,
|
|
@@ -889,7 +889,7 @@ function adjustLayoutByDelta({
|
|
|
889
889
|
if (!fuzzyNumbersEqual(prevSize, safeSize)) {
|
|
890
890
|
deltaApplied += prevSize - safeSize;
|
|
891
891
|
nextLayout[index] = safeSize;
|
|
892
|
-
if (deltaApplied.
|
|
892
|
+
if (deltaApplied.toFixed(3).localeCompare(Math.abs(delta).toFixed(3), undefined, {
|
|
893
893
|
numeric: true
|
|
894
894
|
}) >= 0) {
|
|
895
895
|
break;
|
|
@@ -1339,10 +1339,10 @@ function callPanelCallbacks(panelsArray, layout, panelIdToLastNotifiedSizeMap) {
|
|
|
1339
1339
|
onResize(size, lastNotifiedSize);
|
|
1340
1340
|
}
|
|
1341
1341
|
if (collapsible && (onCollapse || onExpand)) {
|
|
1342
|
-
if (onExpand && (lastNotifiedSize == null || lastNotifiedSize
|
|
1342
|
+
if (onExpand && (lastNotifiedSize == null || fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && !fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
1343
1343
|
onExpand();
|
|
1344
1344
|
}
|
|
1345
|
-
if (onCollapse && (lastNotifiedSize == null || lastNotifiedSize
|
|
1345
|
+
if (onCollapse && (lastNotifiedSize == null || !fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
1346
1346
|
onCollapse();
|
|
1347
1347
|
}
|
|
1348
1348
|
}
|
|
@@ -1379,12 +1379,12 @@ function computePanelFlexBoxStyle({
|
|
|
1379
1379
|
if (size == null) {
|
|
1380
1380
|
// Initial render (before panels have registered themselves)
|
|
1381
1381
|
// In order to support server rendering, fall back to default size if provided
|
|
1382
|
-
flexGrow = defaultSize != undefined ? defaultSize.
|
|
1382
|
+
flexGrow = defaultSize != undefined ? defaultSize.toFixed(precision) : "1";
|
|
1383
1383
|
} else if (panelData.length === 1) {
|
|
1384
1384
|
// Special case: Single panel group should always fill full width/height
|
|
1385
1385
|
flexGrow = "1";
|
|
1386
1386
|
} else {
|
|
1387
|
-
flexGrow = size.
|
|
1387
|
+
flexGrow = size.toFixed(precision);
|
|
1388
1388
|
}
|
|
1389
1389
|
return {
|
|
1390
1390
|
flexBasis: 0,
|
|
@@ -875,7 +875,7 @@ function adjustLayoutByDelta({
|
|
|
875
875
|
if (!fuzzyNumbersEqual(prevSize, safeSize)) {
|
|
876
876
|
deltaApplied += prevSize - safeSize;
|
|
877
877
|
nextLayout[index] = safeSize;
|
|
878
|
-
if (deltaApplied.
|
|
878
|
+
if (deltaApplied.toFixed(3).localeCompare(Math.abs(delta).toFixed(3), undefined, {
|
|
879
879
|
numeric: true
|
|
880
880
|
}) >= 0) {
|
|
881
881
|
break;
|
|
@@ -1201,10 +1201,10 @@ function callPanelCallbacks(panelsArray, layout, panelIdToLastNotifiedSizeMap) {
|
|
|
1201
1201
|
onResize(size, lastNotifiedSize);
|
|
1202
1202
|
}
|
|
1203
1203
|
if (collapsible && (onCollapse || onExpand)) {
|
|
1204
|
-
if (onExpand && (lastNotifiedSize == null || lastNotifiedSize
|
|
1204
|
+
if (onExpand && (lastNotifiedSize == null || fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && !fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
1205
1205
|
onExpand();
|
|
1206
1206
|
}
|
|
1207
|
-
if (onCollapse && (lastNotifiedSize == null || lastNotifiedSize
|
|
1207
|
+
if (onCollapse && (lastNotifiedSize == null || !fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
1208
1208
|
onCollapse();
|
|
1209
1209
|
}
|
|
1210
1210
|
}
|
|
@@ -1241,12 +1241,12 @@ function computePanelFlexBoxStyle({
|
|
|
1241
1241
|
if (size == null) {
|
|
1242
1242
|
// Initial render (before panels have registered themselves)
|
|
1243
1243
|
// In order to support server rendering, fall back to default size if provided
|
|
1244
|
-
flexGrow = defaultSize != undefined ? defaultSize.
|
|
1244
|
+
flexGrow = defaultSize != undefined ? defaultSize.toFixed(precision) : "1";
|
|
1245
1245
|
} else if (panelData.length === 1) {
|
|
1246
1246
|
// Special case: Single panel group should always fill full width/height
|
|
1247
1247
|
flexGrow = "1";
|
|
1248
1248
|
} else {
|
|
1249
|
-
flexGrow = size.
|
|
1249
|
+
flexGrow = size.toFixed(precision);
|
|
1250
1250
|
}
|
|
1251
1251
|
return {
|
|
1252
1252
|
flexBasis: 0,
|
|
@@ -851,7 +851,7 @@ function adjustLayoutByDelta({
|
|
|
851
851
|
if (!fuzzyNumbersEqual(prevSize, safeSize)) {
|
|
852
852
|
deltaApplied += prevSize - safeSize;
|
|
853
853
|
nextLayout[index] = safeSize;
|
|
854
|
-
if (deltaApplied.
|
|
854
|
+
if (deltaApplied.toFixed(3).localeCompare(Math.abs(delta).toFixed(3), undefined, {
|
|
855
855
|
numeric: true
|
|
856
856
|
}) >= 0) {
|
|
857
857
|
break;
|
|
@@ -1177,10 +1177,10 @@ function callPanelCallbacks(panelsArray, layout, panelIdToLastNotifiedSizeMap) {
|
|
|
1177
1177
|
onResize(size, lastNotifiedSize);
|
|
1178
1178
|
}
|
|
1179
1179
|
if (collapsible && (onCollapse || onExpand)) {
|
|
1180
|
-
if (onExpand && (lastNotifiedSize == null || lastNotifiedSize
|
|
1180
|
+
if (onExpand && (lastNotifiedSize == null || fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && !fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
1181
1181
|
onExpand();
|
|
1182
1182
|
}
|
|
1183
|
-
if (onCollapse && (lastNotifiedSize == null || lastNotifiedSize
|
|
1183
|
+
if (onCollapse && (lastNotifiedSize == null || !fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
1184
1184
|
onCollapse();
|
|
1185
1185
|
}
|
|
1186
1186
|
}
|
|
@@ -1217,12 +1217,12 @@ function computePanelFlexBoxStyle({
|
|
|
1217
1217
|
if (size == null) {
|
|
1218
1218
|
// Initial render (before panels have registered themselves)
|
|
1219
1219
|
// In order to support server rendering, fall back to default size if provided
|
|
1220
|
-
flexGrow = defaultSize != undefined ? defaultSize.
|
|
1220
|
+
flexGrow = defaultSize != undefined ? defaultSize.toFixed(precision) : "1";
|
|
1221
1221
|
} else if (panelData.length === 1) {
|
|
1222
1222
|
// Special case: Single panel group should always fill full width/height
|
|
1223
1223
|
flexGrow = "1";
|
|
1224
1224
|
} else {
|
|
1225
|
-
flexGrow = size.
|
|
1225
|
+
flexGrow = size.toFixed(precision);
|
|
1226
1226
|
}
|
|
1227
1227
|
return {
|
|
1228
1228
|
flexBasis: 0,
|
|
@@ -878,7 +878,7 @@ function adjustLayoutByDelta({
|
|
|
878
878
|
if (!fuzzyNumbersEqual(prevSize, safeSize)) {
|
|
879
879
|
deltaApplied += prevSize - safeSize;
|
|
880
880
|
nextLayout[index] = safeSize;
|
|
881
|
-
if (deltaApplied.
|
|
881
|
+
if (deltaApplied.toFixed(3).localeCompare(Math.abs(delta).toFixed(3), undefined, {
|
|
882
882
|
numeric: true
|
|
883
883
|
}) >= 0) {
|
|
884
884
|
break;
|
|
@@ -1318,10 +1318,10 @@ function callPanelCallbacks(panelsArray, layout, panelIdToLastNotifiedSizeMap) {
|
|
|
1318
1318
|
onResize(size, lastNotifiedSize);
|
|
1319
1319
|
}
|
|
1320
1320
|
if (collapsible && (onCollapse || onExpand)) {
|
|
1321
|
-
if (onExpand && (lastNotifiedSize == null || lastNotifiedSize
|
|
1321
|
+
if (onExpand && (lastNotifiedSize == null || fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && !fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
1322
1322
|
onExpand();
|
|
1323
1323
|
}
|
|
1324
|
-
if (onCollapse && (lastNotifiedSize == null || lastNotifiedSize
|
|
1324
|
+
if (onCollapse && (lastNotifiedSize == null || !fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
1325
1325
|
onCollapse();
|
|
1326
1326
|
}
|
|
1327
1327
|
}
|
|
@@ -1358,12 +1358,12 @@ function computePanelFlexBoxStyle({
|
|
|
1358
1358
|
if (size == null) {
|
|
1359
1359
|
// Initial render (before panels have registered themselves)
|
|
1360
1360
|
// In order to support server rendering, fall back to default size if provided
|
|
1361
|
-
flexGrow = defaultSize != undefined ? defaultSize.
|
|
1361
|
+
flexGrow = defaultSize != undefined ? defaultSize.toFixed(precision) : "1";
|
|
1362
1362
|
} else if (panelData.length === 1) {
|
|
1363
1363
|
// Special case: Single panel group should always fill full width/height
|
|
1364
1364
|
flexGrow = "1";
|
|
1365
1365
|
} else {
|
|
1366
|
-
flexGrow = size.
|
|
1366
|
+
flexGrow = size.toFixed(precision);
|
|
1367
1367
|
}
|
|
1368
1368
|
return {
|
|
1369
1369
|
flexBasis: 0,
|
|
@@ -864,7 +864,7 @@ function adjustLayoutByDelta({
|
|
|
864
864
|
if (!fuzzyNumbersEqual(prevSize, safeSize)) {
|
|
865
865
|
deltaApplied += prevSize - safeSize;
|
|
866
866
|
nextLayout[index] = safeSize;
|
|
867
|
-
if (deltaApplied.
|
|
867
|
+
if (deltaApplied.toFixed(3).localeCompare(Math.abs(delta).toFixed(3), undefined, {
|
|
868
868
|
numeric: true
|
|
869
869
|
}) >= 0) {
|
|
870
870
|
break;
|
|
@@ -1190,10 +1190,10 @@ function callPanelCallbacks(panelsArray, layout, panelIdToLastNotifiedSizeMap) {
|
|
|
1190
1190
|
onResize(size, lastNotifiedSize);
|
|
1191
1191
|
}
|
|
1192
1192
|
if (collapsible && (onCollapse || onExpand)) {
|
|
1193
|
-
if (onExpand && (lastNotifiedSize == null || lastNotifiedSize
|
|
1193
|
+
if (onExpand && (lastNotifiedSize == null || fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && !fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
1194
1194
|
onExpand();
|
|
1195
1195
|
}
|
|
1196
|
-
if (onCollapse && (lastNotifiedSize == null || lastNotifiedSize
|
|
1196
|
+
if (onCollapse && (lastNotifiedSize == null || !fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
1197
1197
|
onCollapse();
|
|
1198
1198
|
}
|
|
1199
1199
|
}
|
|
@@ -1230,12 +1230,12 @@ function computePanelFlexBoxStyle({
|
|
|
1230
1230
|
if (size == null) {
|
|
1231
1231
|
// Initial render (before panels have registered themselves)
|
|
1232
1232
|
// In order to support server rendering, fall back to default size if provided
|
|
1233
|
-
flexGrow = defaultSize != undefined ? defaultSize.
|
|
1233
|
+
flexGrow = defaultSize != undefined ? defaultSize.toFixed(precision) : "1";
|
|
1234
1234
|
} else if (panelData.length === 1) {
|
|
1235
1235
|
// Special case: Single panel group should always fill full width/height
|
|
1236
1236
|
flexGrow = "1";
|
|
1237
1237
|
} else {
|
|
1238
|
-
flexGrow = size.
|
|
1238
|
+
flexGrow = size.toFixed(precision);
|
|
1239
1239
|
}
|
|
1240
1240
|
return {
|
|
1241
1241
|
flexBasis: 0,
|
|
@@ -840,7 +840,7 @@ function adjustLayoutByDelta({
|
|
|
840
840
|
if (!fuzzyNumbersEqual(prevSize, safeSize)) {
|
|
841
841
|
deltaApplied += prevSize - safeSize;
|
|
842
842
|
nextLayout[index] = safeSize;
|
|
843
|
-
if (deltaApplied.
|
|
843
|
+
if (deltaApplied.toFixed(3).localeCompare(Math.abs(delta).toFixed(3), undefined, {
|
|
844
844
|
numeric: true
|
|
845
845
|
}) >= 0) {
|
|
846
846
|
break;
|
|
@@ -1166,10 +1166,10 @@ function callPanelCallbacks(panelsArray, layout, panelIdToLastNotifiedSizeMap) {
|
|
|
1166
1166
|
onResize(size, lastNotifiedSize);
|
|
1167
1167
|
}
|
|
1168
1168
|
if (collapsible && (onCollapse || onExpand)) {
|
|
1169
|
-
if (onExpand && (lastNotifiedSize == null || lastNotifiedSize
|
|
1169
|
+
if (onExpand && (lastNotifiedSize == null || fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && !fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
1170
1170
|
onExpand();
|
|
1171
1171
|
}
|
|
1172
|
-
if (onCollapse && (lastNotifiedSize == null || lastNotifiedSize
|
|
1172
|
+
if (onCollapse && (lastNotifiedSize == null || !fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
1173
1173
|
onCollapse();
|
|
1174
1174
|
}
|
|
1175
1175
|
}
|
|
@@ -1206,12 +1206,12 @@ function computePanelFlexBoxStyle({
|
|
|
1206
1206
|
if (size == null) {
|
|
1207
1207
|
// Initial render (before panels have registered themselves)
|
|
1208
1208
|
// In order to support server rendering, fall back to default size if provided
|
|
1209
|
-
flexGrow = defaultSize != undefined ? defaultSize.
|
|
1209
|
+
flexGrow = defaultSize != undefined ? defaultSize.toFixed(precision) : "1";
|
|
1210
1210
|
} else if (panelData.length === 1) {
|
|
1211
1211
|
// Special case: Single panel group should always fill full width/height
|
|
1212
1212
|
flexGrow = "1";
|
|
1213
1213
|
} else {
|
|
1214
|
-
flexGrow = size.
|
|
1214
|
+
flexGrow = size.toFixed(precision);
|
|
1215
1215
|
}
|
|
1216
1216
|
return {
|
|
1217
1217
|
flexBasis: 0,
|
package/package.json
CHANGED
package/src/Panel.test.tsx
CHANGED
|
@@ -545,6 +545,44 @@ describe("PanelGroup", () => {
|
|
|
545
545
|
|
|
546
546
|
expect(onCollapse).toHaveBeenCalledTimes(1);
|
|
547
547
|
});
|
|
548
|
+
|
|
549
|
+
it("should be called with collapsedSizes that have many decimal places", () => {
|
|
550
|
+
let onCollapse = jest.fn();
|
|
551
|
+
|
|
552
|
+
let panelRef = createRef<ImperativePanelHandle>();
|
|
553
|
+
|
|
554
|
+
act(() => {
|
|
555
|
+
root.render(
|
|
556
|
+
<PanelGroup direction="horizontal">
|
|
557
|
+
<Panel
|
|
558
|
+
collapsible
|
|
559
|
+
onCollapse={onCollapse}
|
|
560
|
+
collapsedSize={3.8764385221078133}
|
|
561
|
+
minSize={10}
|
|
562
|
+
ref={panelRef}
|
|
563
|
+
/>
|
|
564
|
+
<PanelResizeHandle />
|
|
565
|
+
<Panel />
|
|
566
|
+
</PanelGroup>
|
|
567
|
+
);
|
|
568
|
+
});
|
|
569
|
+
expect(onCollapse).not.toHaveBeenCalled();
|
|
570
|
+
|
|
571
|
+
act(() => {
|
|
572
|
+
panelRef.current?.collapse();
|
|
573
|
+
});
|
|
574
|
+
expect(onCollapse).toHaveBeenCalledTimes(1);
|
|
575
|
+
|
|
576
|
+
act(() => {
|
|
577
|
+
panelRef.current?.expand();
|
|
578
|
+
});
|
|
579
|
+
expect(onCollapse).toHaveBeenCalledTimes(1);
|
|
580
|
+
|
|
581
|
+
act(() => {
|
|
582
|
+
panelRef.current?.collapse();
|
|
583
|
+
});
|
|
584
|
+
expect(onCollapse).toHaveBeenCalledTimes(2);
|
|
585
|
+
});
|
|
548
586
|
});
|
|
549
587
|
|
|
550
588
|
describe("onExpand", () => {
|
|
@@ -594,6 +632,45 @@ describe("PanelGroup", () => {
|
|
|
594
632
|
|
|
595
633
|
expect(onExpand).toHaveBeenCalledTimes(1);
|
|
596
634
|
});
|
|
635
|
+
|
|
636
|
+
it("should be called with collapsedSizes that have many decimal places", () => {
|
|
637
|
+
let onExpand = jest.fn();
|
|
638
|
+
|
|
639
|
+
let panelRef = createRef<ImperativePanelHandle>();
|
|
640
|
+
|
|
641
|
+
act(() => {
|
|
642
|
+
root.render(
|
|
643
|
+
<PanelGroup direction="horizontal">
|
|
644
|
+
<Panel
|
|
645
|
+
collapsible
|
|
646
|
+
collapsedSize={3.8764385221078133}
|
|
647
|
+
defaultSize={3.8764385221078133}
|
|
648
|
+
minSize={10}
|
|
649
|
+
onExpand={onExpand}
|
|
650
|
+
ref={panelRef}
|
|
651
|
+
/>
|
|
652
|
+
<PanelResizeHandle />
|
|
653
|
+
<Panel />
|
|
654
|
+
</PanelGroup>
|
|
655
|
+
);
|
|
656
|
+
});
|
|
657
|
+
expect(onExpand).not.toHaveBeenCalled();
|
|
658
|
+
|
|
659
|
+
act(() => {
|
|
660
|
+
panelRef.current?.resize(25);
|
|
661
|
+
});
|
|
662
|
+
expect(onExpand).toHaveBeenCalledTimes(1);
|
|
663
|
+
|
|
664
|
+
act(() => {
|
|
665
|
+
panelRef.current?.collapse();
|
|
666
|
+
});
|
|
667
|
+
expect(onExpand).toHaveBeenCalledTimes(1);
|
|
668
|
+
|
|
669
|
+
act(() => {
|
|
670
|
+
panelRef.current?.expand();
|
|
671
|
+
});
|
|
672
|
+
expect(onExpand).toHaveBeenCalledTimes(2);
|
|
673
|
+
});
|
|
597
674
|
});
|
|
598
675
|
|
|
599
676
|
describe("onResize", () => {
|
|
@@ -723,6 +800,33 @@ describe("PanelGroup", () => {
|
|
|
723
800
|
expect(onResizeRight).not.toHaveBeenCalled();
|
|
724
801
|
});
|
|
725
802
|
});
|
|
803
|
+
|
|
804
|
+
it("should support sizes with many decimal places", () => {
|
|
805
|
+
let panelRef = createRef<ImperativePanelHandle>();
|
|
806
|
+
let onResize = jest.fn();
|
|
807
|
+
|
|
808
|
+
act(() => {
|
|
809
|
+
root.render(
|
|
810
|
+
<PanelGroup direction="horizontal">
|
|
811
|
+
<Panel onResize={onResize} ref={panelRef} />
|
|
812
|
+
<PanelResizeHandle />
|
|
813
|
+
<Panel />
|
|
814
|
+
</PanelGroup>
|
|
815
|
+
);
|
|
816
|
+
});
|
|
817
|
+
expect(onResize).toHaveBeenCalledTimes(1);
|
|
818
|
+
|
|
819
|
+
act(() => {
|
|
820
|
+
panelRef.current?.resize(3.8764385221078133);
|
|
821
|
+
});
|
|
822
|
+
expect(onResize).toHaveBeenCalledTimes(2);
|
|
823
|
+
|
|
824
|
+
// An overly-high precision change should be ignored
|
|
825
|
+
act(() => {
|
|
826
|
+
panelRef.current?.resize(3.8764385221078132);
|
|
827
|
+
});
|
|
828
|
+
expect(onResize).toHaveBeenCalledTimes(2);
|
|
829
|
+
});
|
|
726
830
|
});
|
|
727
831
|
|
|
728
832
|
describe("data attributes", () => {
|
|
@@ -200,8 +200,8 @@ export function adjustLayoutByDelta({
|
|
|
200
200
|
|
|
201
201
|
if (
|
|
202
202
|
deltaApplied
|
|
203
|
-
.
|
|
204
|
-
.localeCompare(Math.abs(delta).
|
|
203
|
+
.toFixed(3)
|
|
204
|
+
.localeCompare(Math.abs(delta).toFixed(3), undefined, {
|
|
205
205
|
numeric: true,
|
|
206
206
|
}) >= 0
|
|
207
207
|
) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PanelData } from "../Panel";
|
|
2
2
|
import { assert } from "./assert";
|
|
3
|
+
import { fuzzyNumbersEqual } from "./numbers/fuzzyCompareNumbers";
|
|
3
4
|
|
|
4
5
|
// Layout should be pre-converted into percentages
|
|
5
6
|
export function callPanelCallbacks(
|
|
@@ -27,16 +28,18 @@ export function callPanelCallbacks(
|
|
|
27
28
|
if (collapsible && (onCollapse || onExpand)) {
|
|
28
29
|
if (
|
|
29
30
|
onExpand &&
|
|
30
|
-
(lastNotifiedSize == null ||
|
|
31
|
-
|
|
31
|
+
(lastNotifiedSize == null ||
|
|
32
|
+
fuzzyNumbersEqual(lastNotifiedSize, collapsedSize)) &&
|
|
33
|
+
!fuzzyNumbersEqual(size, collapsedSize)
|
|
32
34
|
) {
|
|
33
35
|
onExpand();
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
if (
|
|
37
39
|
onCollapse &&
|
|
38
|
-
(lastNotifiedSize == null ||
|
|
39
|
-
|
|
40
|
+
(lastNotifiedSize == null ||
|
|
41
|
+
!fuzzyNumbersEqual(lastNotifiedSize, collapsedSize)) &&
|
|
42
|
+
fuzzyNumbersEqual(size, collapsedSize)
|
|
40
43
|
) {
|
|
41
44
|
onCollapse();
|
|
42
45
|
}
|
|
@@ -26,13 +26,12 @@ export function computePanelFlexBoxStyle({
|
|
|
26
26
|
if (size == null) {
|
|
27
27
|
// Initial render (before panels have registered themselves)
|
|
28
28
|
// In order to support server rendering, fall back to default size if provided
|
|
29
|
-
flexGrow =
|
|
30
|
-
defaultSize != undefined ? defaultSize.toPrecision(precision) : "1";
|
|
29
|
+
flexGrow = defaultSize != undefined ? defaultSize.toFixed(precision) : "1";
|
|
31
30
|
} else if (panelData.length === 1) {
|
|
32
31
|
// Special case: Single panel group should always fill full width/height
|
|
33
32
|
flexGrow = "1";
|
|
34
33
|
} else {
|
|
35
|
-
flexGrow = size.
|
|
34
|
+
flexGrow = size.toFixed(precision);
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
return {
|