chore: support click to show choose add var

This commit is contained in:
Joel 2024-04-03 14:57:07 +08:00
parent 28e813f57f
commit bd3b400121
1 changed files with 12 additions and 1 deletions

View File

@ -76,10 +76,21 @@ const Editor: FC<Props> = ({
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)
}