From be82fe2a8ce37bac7205a1a43abeca396fdadba6 Mon Sep 17 00:00:00 2001 From: Eric Zhu Date: Mon, 4 Nov 2024 23:02:49 +0800 Subject: [PATCH] feat(renderer): prevent currently executing async entry action from being executed again (#1348) * feat(renderer): prevent currently executing async entry action from being executed again * move logic to the ActionButton component --- packages/components/src/ui/button/index.tsx | 31 +++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/packages/components/src/ui/button/index.tsx b/packages/components/src/ui/button/index.tsx index 9140c1521..4a1cf38ba 100644 --- a/packages/components/src/ui/button/index.tsx +++ b/packages/components/src/ui/button/index.tsx @@ -6,6 +6,7 @@ import type { VariantProps } from "class-variance-authority" import type { HTMLMotionProps } from "framer-motion" import { m } from "framer-motion" import * as React from "react" +import { useState } from "react" import type { Options } from "react-hotkeys-hook" import { useHotkeys } from "react-hotkeys-hook" @@ -60,6 +61,7 @@ export const ActionButton = React.forwardRef< disableTriggerShortcut, size = "base", shortcutOnlyFocusWithIn, + onClick, ...rest }, ref, @@ -69,6 +71,8 @@ export const ActionButton = React.forwardRef< const buttonRef = React.useRef(null) React.useImperativeHandle(ref, () => buttonRef.current!) + const [loading, setLoading] = useState(false) + const Trigger = (