mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 05:45:55 +08:00
fix: start node input config modal raise 'variable name is required' (#8793)
This commit is contained in:
parent
d1173a69f8
commit
62406991df
@ -1,6 +1,6 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import type { FC } from 'react'
|
import type { FC } from 'react'
|
||||||
import React, { useCallback, useState } from 'react'
|
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { useContext } from 'use-context-selector'
|
import { useContext } from 'use-context-selector'
|
||||||
import ModalFoot from '../modal-foot'
|
import ModalFoot from '../modal-foot'
|
||||||
@ -40,6 +40,12 @@ const ConfigModal: FC<IConfigModalProps> = ({
|
|||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const [tempPayload, setTempPayload] = useState<InputVar>(payload || getNewVarInWorkflow('') as any)
|
const [tempPayload, setTempPayload] = useState<InputVar>(payload || getNewVarInWorkflow('') as any)
|
||||||
const { type, label, variable, options, max_length } = tempPayload
|
const { type, label, variable, options, max_length } = tempPayload
|
||||||
|
const modalRef = useRef<HTMLDivElement>(null)
|
||||||
|
useEffect(() => {
|
||||||
|
// To fix the first input element auto focus, then directly close modal will raise error
|
||||||
|
if (isShow)
|
||||||
|
modalRef.current?.focus()
|
||||||
|
}, [isShow])
|
||||||
|
|
||||||
const isStringInput = type === InputVarType.textInput || type === InputVarType.paragraph
|
const isStringInput = type === InputVarType.textInput || type === InputVarType.paragraph
|
||||||
const checkVariableName = useCallback((value: string) => {
|
const checkVariableName = useCallback((value: string) => {
|
||||||
@ -135,7 +141,7 @@ const ConfigModal: FC<IConfigModalProps> = ({
|
|||||||
isShow={isShow}
|
isShow={isShow}
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
>
|
>
|
||||||
<div className='mb-8'>
|
<div className='mb-8' ref={modalRef} tabIndex={-1}>
|
||||||
<div className='space-y-2'>
|
<div className='space-y-2'>
|
||||||
|
|
||||||
<Field title={t('appDebug.variableConfig.fieldType')}>
|
<Field title={t('appDebug.variableConfig.fieldType')}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user