Browse Source

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

tags/1.8.1
zyileven 2 months ago
parent
commit
bcac43c812
No account linked to committer's email address

+ 5
- 2
web/app/components/base/tag-input/index.tsx View File

customizedConfirmKey?: 'Enter' | 'Tab' customizedConfirmKey?: 'Enter' | 'Tab'
isInWorkflow?: boolean isInWorkflow?: boolean
placeholder?: string placeholder?: string
required?: boolean
} }


const TagInput: FC<TagInputProps> = ({ 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()
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
} }


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

+ 1
- 0
web/app/components/header/account-setting/model-provider-page/model-parameter-modal/parameter-item.tsx View File

onChange={handleTagChange} onChange={handleTagChange}
customizedConfirmKey='Tab' customizedConfirmKey='Tab'
isInWorkflow={isInWorkflow} isInWorkflow={isInWorkflow}
required={parameterRule.required}
/> />
</div> </div>
) )

Loading…
Cancel
Save