fix(web): fix error notify when tagInput component is not required (#… (#24774)

This commit is contained in:
zyileven
2025-08-29 15:30:40 +08:00
committed by GitHub
parent 929d9e0b3f
commit bcac43c812
2 changed files with 6 additions and 2 deletions

View File

@@ -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')

View File

@@ -236,6 +236,7 @@ const ParameterItem: FC<ParameterItemProps> = ({
onChange={handleTagChange}
customizedConfirmKey='Tab'
isInWorkflow={isInWorkflow}
required={parameterRule.required}
/>
</div>
)