@react-aria/dnd 3.1.1-nightly.3764 → 3.1.1-nightly.3785

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/dist/import.mjs CHANGED
@@ -2366,7 +2366,7 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
2366
2366
  y = size.height / 2;
2367
2367
  }
2368
2368
  // Rounding height to an even number prevents blurry preview seen on some screens
2369
- let height = 2 * Math.round(rect.height / 2);
2369
+ let height = 2 * Math.round(size.height / 2);
2370
2370
  node.style.height = `${height}px`;
2371
2371
  e.dataTransfer.setDragImage(node, x, y);
2372
2372
  });
@@ -3051,11 +3051,17 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
3051
3051
  });
3052
3052
  let droppingState = (0, $fP8tg$useRef)(null);
3053
3053
  let onDrop = (0, $fP8tg$useCallback)((e, target)=>{
3054
+ var _state_collection_getItem;
3054
3055
  let { state: state } = localState;
3055
3056
  // Focus the collection.
3056
3057
  state.selectionManager.setFocused(true);
3057
3058
  // Save some state of the collection/selection before the drop occurs so we can compare later.
3058
3059
  let focusedKey = state.selectionManager.focusedKey;
3060
+ // If parent key was dragged, we want to use it instead (i.e. focus row instead of cell after dropping)
3061
+ if ((0, $7252cd45fc48c07c$export$6ca6700462636d0b).draggingKeys.has((_state_collection_getItem = state.collection.getItem(focusedKey)) === null || _state_collection_getItem === void 0 ? void 0 : _state_collection_getItem.parentKey)) {
3062
+ focusedKey = state.collection.getItem(focusedKey).parentKey;
3063
+ state.selectionManager.setFocusedKey(focusedKey);
3064
+ }
3059
3065
  droppingState.current = {
3060
3066
  timeout: null,
3061
3067
  focusedKey: focusedKey,
@@ -3510,8 +3516,12 @@ function $ddf25448c71fc93a$export$8d0e41d2815afac5(props, state, ref) {
3510
3516
  itemText: getText(target.key)
3511
3517
  });
3512
3518
  else {
3513
- let before = target.dropPosition === "before" ? collection.getKeyBefore(target.key) : target.key;
3514
- let after = target.dropPosition === "after" ? collection.getKeyAfter(target.key) : target.key;
3519
+ let before;
3520
+ let after;
3521
+ if (collection.getFirstKey() === target.key && target.dropPosition === "before") before = null;
3522
+ else before = target.dropPosition === "before" ? collection.getKeyBefore(target.key) : target.key;
3523
+ if (collection.getLastKey() === target.key && target.dropPosition === "after") after = null;
3524
+ else after = target.dropPosition === "after" ? collection.getKeyAfter(target.key) : target.key;
3515
3525
  if (before && after) label = stringFormatter.format("insertBetween", {
3516
3526
  beforeItemText: getText(before),
3517
3527
  afterItemText: getText(after)
package/dist/main.js CHANGED
@@ -2385,7 +2385,7 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
2385
2385
  y = size.height / 2;
2386
2386
  }
2387
2387
  // Rounding height to an even number prevents blurry preview seen on some screens
2388
- let height = 2 * Math.round(rect.height / 2);
2388
+ let height = 2 * Math.round(size.height / 2);
2389
2389
  node.style.height = `${height}px`;
2390
2390
  e.dataTransfer.setDragImage(node, x, y);
2391
2391
  });
@@ -3070,11 +3070,17 @@ function $7f93a158ac20b90a$export$f4e2f423c21f7b04(props, state, ref) {
3070
3070
  });
3071
3071
  let droppingState = (0, $4vY0V$react.useRef)(null);
3072
3072
  let onDrop = (0, $4vY0V$react.useCallback)((e, target)=>{
3073
+ var _state_collection_getItem;
3073
3074
  let { state: state } = localState;
3074
3075
  // Focus the collection.
3075
3076
  state.selectionManager.setFocused(true);
3076
3077
  // Save some state of the collection/selection before the drop occurs so we can compare later.
3077
3078
  let focusedKey = state.selectionManager.focusedKey;
3079
+ // If parent key was dragged, we want to use it instead (i.e. focus row instead of cell after dropping)
3080
+ if ((0, $4620ae0dc40f0031$export$6ca6700462636d0b).draggingKeys.has((_state_collection_getItem = state.collection.getItem(focusedKey)) === null || _state_collection_getItem === void 0 ? void 0 : _state_collection_getItem.parentKey)) {
3081
+ focusedKey = state.collection.getItem(focusedKey).parentKey;
3082
+ state.selectionManager.setFocusedKey(focusedKey);
3083
+ }
3078
3084
  droppingState.current = {
3079
3085
  timeout: null,
3080
3086
  focusedKey: focusedKey,
@@ -3529,8 +3535,12 @@ function $c5557edbed563ebf$export$8d0e41d2815afac5(props, state, ref) {
3529
3535
  itemText: getText(target.key)
3530
3536
  });
3531
3537
  else {
3532
- let before = target.dropPosition === "before" ? collection.getKeyBefore(target.key) : target.key;
3533
- let after = target.dropPosition === "after" ? collection.getKeyAfter(target.key) : target.key;
3538
+ let before;
3539
+ let after;
3540
+ if (collection.getFirstKey() === target.key && target.dropPosition === "before") before = null;
3541
+ else before = target.dropPosition === "before" ? collection.getKeyBefore(target.key) : target.key;
3542
+ if (collection.getLastKey() === target.key && target.dropPosition === "after") after = null;
3543
+ else after = target.dropPosition === "after" ? collection.getKeyAfter(target.key) : target.key;
3534
3544
  if (before && after) label = stringFormatter.format("insertBetween", {
3535
3545
  beforeItemText: getText(before),
3536
3546
  afterItemText: getText(after)