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