mirror of
https://github.com/langgenius/dify.git
synced 2026-04-28 03:36:36 +08:00
fix(web): fix error notify when tagInput component is not required (#… (#24774)
This commit is contained in:
parent
929d9e0b3f
commit
bcac43c812
@ -14,6 +14,7 @@ type TagInputProps = {
|
|||||||
customizedConfirmKey?: 'Enter' | 'Tab'
|
customizedConfirmKey?: 'Enter' | 'Tab'
|
||||||
isInWorkflow?: boolean
|
isInWorkflow?: boolean
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
|
required?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const TagInput: FC<TagInputProps> = ({
|
const TagInput: FC<TagInputProps> = ({
|
||||||
@ -24,6 +25,7 @@ const TagInput: FC<TagInputProps> = ({
|
|||||||
customizedConfirmKey = 'Enter',
|
customizedConfirmKey = 'Enter',
|
||||||
isInWorkflow,
|
isInWorkflow,
|
||||||
placeholder,
|
placeholder,
|
||||||
|
required = false,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { notify } = useToastContext()
|
const { notify } = useToastContext()
|
||||||
@ -42,7 +44,8 @@ const TagInput: FC<TagInputProps> = ({
|
|||||||
const handleNewTag = useCallback((value: string) => {
|
const handleNewTag = useCallback((value: string) => {
|
||||||
const valueTrimmed = value.trim()
|
const valueTrimmed = value.trim()
|
||||||
if (!valueTrimmed) {
|
if (!valueTrimmed) {
|
||||||
notify({ type: 'error', message: t('datasetDocuments.segment.keywordEmpty') })
|
if (required)
|
||||||
|
notify({ type: 'error', message: t('datasetDocuments.segment.keywordEmpty') })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +63,7 @@ const TagInput: FC<TagInputProps> = ({
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setValue('')
|
setValue('')
|
||||||
})
|
})
|
||||||
}, [items, onChange, notify, t])
|
}, [items, onChange, notify, t, required])
|
||||||
|
|
||||||
const handleKeyDown = (e: KeyboardEvent) => {
|
const handleKeyDown = (e: KeyboardEvent) => {
|
||||||
if (isSpecialMode && e.key === 'Enter')
|
if (isSpecialMode && e.key === 'Enter')
|
||||||
|
|||||||
@ -236,6 +236,7 @@ const ParameterItem: FC<ParameterItemProps> = ({
|
|||||||
onChange={handleTagChange}
|
onChange={handleTagChange}
|
||||||
customizedConfirmKey='Tab'
|
customizedConfirmKey='Tab'
|
||||||
isInWorkflow={isInWorkflow}
|
isInWorkflow={isInWorkflow}
|
||||||
|
required={parameterRule.required}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user