mirror of https://github.com/langgenius/dify.git
fix @ input problem
This commit is contained in:
parent
827a1b181b
commit
37ecd4a0bc
|
|
@ -223,7 +223,10 @@ export const MentionInput: FC<MentionInputProps> = memo(({
|
|||
|
||||
const beforeMention = value.slice(0, mentionPosition)
|
||||
const afterMention = value.slice(textarea.selectionStart || 0)
|
||||
const newContent = `${beforeMention}@${user.name} ${afterMention}`
|
||||
|
||||
const needsSpaceBefore = mentionPosition > 0 && !/\s/.test(value[mentionPosition - 1])
|
||||
const prefix = needsSpaceBefore ? ' ' : ''
|
||||
const newContent = `${beforeMention}${prefix}@${user.name} ${afterMention}`
|
||||
|
||||
onChange(newContent)
|
||||
setShowMentionDropdown(false)
|
||||
|
|
@ -232,7 +235,8 @@ export const MentionInput: FC<MentionInputProps> = memo(({
|
|||
setMentionedUserIds(newMentionedUserIds)
|
||||
|
||||
setTimeout(() => {
|
||||
const newCursorPos = mentionPosition + user.name.length + 2 // @ + name + space
|
||||
const extraSpace = needsSpaceBefore ? 1 : 0
|
||||
const newCursorPos = mentionPosition + extraSpace + user.name.length + 2 // (space) + @ + name + space
|
||||
textarea.setSelectionRange(newCursorPos, newCursorPos)
|
||||
textarea.focus()
|
||||
}, 0)
|
||||
|
|
|
|||
|
|
@ -377,7 +377,6 @@ export const CommentThread: FC<CommentThreadProps> = memo(({
|
|||
placeholder={t('workflow.comments.placeholder.reply')}
|
||||
disabled={loading}
|
||||
loading={loading}
|
||||
className='px-2'
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue