@ornikar/kitt-universal 25.55.0 → 25.56.0

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.
@@ -3625,6 +3625,8 @@ var ActionsItem = /*#__PURE__*/forwardRef(function (_ref, ref) {
3625
3625
  isLoading = _useState2[0],
3626
3626
  setIsLoading = _useState2[1];
3627
3627
  var mountedRef = useRef(false);
3628
+ // securing the loading state with a ref to avoid user action between rerenders
3629
+ var loadingRef = useRef(false);
3628
3630
 
3629
3631
  // effect just for tracking mounted state, as onPress can unmount the ActionButton
3630
3632
  useEffect(function () {
@@ -3646,34 +3648,37 @@ var ActionsItem = /*#__PURE__*/forwardRef(function (_ref, ref) {
3646
3648
  return _regeneratorRuntime().wrap(function (_context) {
3647
3649
  while (1) switch (_context.prev = _context.next) {
3648
3650
  case 0:
3649
- if (onPress) {
3651
+ if (!(!onPress || loadingRef.current)) {
3650
3652
  _context.next = 2;
3651
3653
  break;
3652
3654
  }
3653
3655
  return _context.abrupt("return");
3654
3656
  case 2:
3655
3657
  setIsLoading(true);
3656
- _context.prev = 3;
3657
- _context.next = 6;
3658
+ loadingRef.current = true;
3659
+ _context.prev = 4;
3660
+ _context.next = 7;
3658
3661
  return onPress(e);
3659
- case 6:
3662
+ case 7:
3660
3663
  if (mountedRef.current) {
3661
3664
  setIsLoading(false);
3665
+ loadingRef.current = false;
3662
3666
  }
3663
- _context.next = 13;
3667
+ _context.next = 14;
3664
3668
  break;
3665
- case 9:
3666
- _context.prev = 9;
3667
- _context.t0 = _context["catch"](3);
3669
+ case 10:
3670
+ _context.prev = 10;
3671
+ _context.t0 = _context["catch"](4);
3668
3672
  if (mountedRef.current) {
3673
+ loadingRef.current = false;
3669
3674
  setIsLoading(false);
3670
3675
  }
3671
3676
  throw _context.t0;
3672
- case 13:
3677
+ case 14:
3673
3678
  case "end":
3674
3679
  return _context.stop();
3675
3680
  }
3676
- }, _callee, null, [[3, 9]]);
3681
+ }, _callee, null, [[4, 10]]);
3677
3682
  }));
3678
3683
  return function () {
3679
3684
  return _ref2.apply(this, arguments);