From bd3b400121b95719e09a93d269836e179793a331 Mon Sep 17 00:00:00 2001 From: Joel Date: Wed, 3 Apr 2024 14:57:07 +0800 Subject: [PATCH] chore: support click to show choose add var --- .../nodes/_base/components/prompt/editor.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx b/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx index 182e55370b..2f198d8338 100644 --- a/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx +++ b/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx @@ -76,10 +76,21 @@ const Editor: FC = ({ const [isFocus, { setTrue: setFocus, - setFalse: setBlur, + setFalse: doSetBlur, }] = useBoolean(false) + const notBlur = useRef(false) + + const setBlur = () => { + // delay to avoid to not handle click event(handleInsertVariable) + setTimeout(() => { + if (!notBlur.current) + doSetBlur() + notBlur.current = false + }, 500) + } const handleInsertVariable = () => { + notBlur.current = true setFocus() eventEmitter?.emit({ type: PROMPT_EDITOR_INSERT_QUICKLY, instanceId } as any) }