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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

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

View File

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