@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.
@@ -3611,6 +3611,8 @@ const ActionsItem = /*#__PURE__*/react.forwardRef(({
3611
3611
  }, ref) => {
3612
3612
  const [isLoading, setIsLoading] = react.useState(false);
3613
3613
  const mountedRef = react.useRef(false);
3614
+ // securing the loading state with a ref to avoid user action between rerenders
3615
+ const loadingRef = react.useRef(false);
3614
3616
 
3615
3617
  // effect just for tracking mounted state, as onPress can unmount the ActionButton
3616
3618
  react.useEffect(() => {
@@ -3628,15 +3630,18 @@ const ActionsItem = /*#__PURE__*/react.forwardRef(({
3628
3630
  icon: isLoading ? /*#__PURE__*/jsxRuntime.jsx(LoaderIcon, {}) : icon,
3629
3631
  onPress: e => {
3630
3632
  (async () => {
3631
- if (!onPress) return;
3633
+ if (!onPress || loadingRef.current) return;
3632
3634
  setIsLoading(true);
3635
+ loadingRef.current = true;
3633
3636
  try {
3634
3637
  await onPress(e);
3635
3638
  if (mountedRef.current) {
3636
3639
  setIsLoading(false);
3640
+ loadingRef.current = false;
3637
3641
  }
3638
3642
  } catch (error) {
3639
3643
  if (mountedRef.current) {
3644
+ loadingRef.current = false;
3640
3645
  setIsLoading(false);
3641
3646
  }
3642
3647
  throw error;