@rpg-engine/long-bow 0.7.80 → 0.7.81

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.
@@ -27815,6 +27815,7 @@ var ItemSlot = /*#__PURE__*/observer(function (_ref) {
27815
27815
  updateDetailsState = _useItemSlotDetails.updateDetailsState,
27816
27816
  setContextActions = _useItemSlotDetails.setContextActions;
27817
27817
  var isContextMenuVisible = detailsState.isContextMenuVisible,
27818
+ clearDetailsState = detailsState.clearDetailsState,
27818
27819
  clearContextActions = detailsState.clearContextActions;
27819
27820
  var dragContainer = useRef(null);
27820
27821
  var _useItemSlotDragging = useItemSlotDragging(),
@@ -27834,12 +27835,17 @@ var ItemSlot = /*#__PURE__*/observer(function (_ref) {
27834
27835
  isFocused: false
27835
27836
  });
27836
27837
  }, [containerType, isDepotSystem, setContextActions, clearContextActions, isContextMenuDisabled]);
27838
+ useEffect(function () {
27839
+ // Reset drag position and focus when item changes
27840
+ clearDraggingState();
27841
+ // Clear context actions when component unmounts or dependencies change
27842
+ return function () {
27843
+ clearContextActions();
27844
+ };
27845
+ }, [containerType, isDepotSystem, setContextActions, clearContextActions, isContextMenuDisabled, updateDraggingState]);
27837
27846
  var resetItem = function resetItem() {
27838
27847
  clearDraggingState();
27839
- updateDetailsState({
27840
- item: item,
27841
- isTooltipVisible: false
27842
- });
27848
+ clearDetailsState();
27843
27849
  };
27844
27850
  var onSuccessfulDrag = function onSuccessfulDrag(quantity) {
27845
27851
  resetItem();
@@ -27945,12 +27951,12 @@ var ItemSlot = /*#__PURE__*/observer(function (_ref) {
27945
27951
  y: matrix.m42
27946
27952
  };
27947
27953
  };
27948
- /**
27949
- * Processes the end of a drag event, handling quantity selection or resetting state.
27950
- */
27951
- var processDragEnd = function processDragEnd(item) {
27954
+ var processDragEnd = useCallback(function (item) {
27952
27955
  if (checkIfItemCanBeMoved != null && checkIfItemCanBeMoved()) {
27953
- if (checkIfItemShouldDragEnd && !checkIfItemShouldDragEnd()) return;
27956
+ if (checkIfItemShouldDragEnd && !checkIfItemShouldDragEnd()) {
27957
+ resetItem();
27958
+ return;
27959
+ }
27954
27960
  if (item.stackQty && item.stackQty !== 1 && openQuantitySelector) {
27955
27961
  openQuantitySelector(item.stackQty, onSuccessfulDrag);
27956
27962
  } else {
@@ -27958,15 +27964,8 @@ var ItemSlot = /*#__PURE__*/observer(function (_ref) {
27958
27964
  }
27959
27965
  } else {
27960
27966
  resetItem();
27961
- updateDraggingState({
27962
- isFocused: false,
27963
- position: {
27964
- x: 0,
27965
- y: 0
27966
- }
27967
- });
27968
27967
  }
27969
- };
27968
+ }, [checkIfItemCanBeMoved, checkIfItemShouldDragEnd, openQuantitySelector, onSuccessfulDrag, resetItem]);
27970
27969
  /**
27971
27970
  * Handles the context menu or tooltip display after dragging stops without a drop.
27972
27971
  */