From 28c0748001e205083f39466e03e928e40c602baa Mon Sep 17 00:00:00 2001 From: vic123 Date: Mon, 24 Feb 2025 10:15:08 +0800 Subject: [PATCH] fix: undesired assistant selection menu popup when no ' ' before '@' --- src/renderer/src/pages/home/Inputbar/MentionModelsButton.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/pages/home/Inputbar/MentionModelsButton.tsx b/src/renderer/src/pages/home/Inputbar/MentionModelsButton.tsx index 36ce439f..ba0d5761 100644 --- a/src/renderer/src/pages/home/Inputbar/MentionModelsButton.tsx +++ b/src/renderer/src/pages/home/Inputbar/MentionModelsButton.tsx @@ -231,14 +231,14 @@ const MentionModelsButton: FC = ({ mentionModels, onMentionModel: onSelec const cursorPosition = textArea.selectionStart const textBeforeCursor = textArea.value.substring(0, cursorPosition) const lastAtIndex = textBeforeCursor.lastIndexOf('@') - + const textBeforeLastAt = textBeforeCursor.slice(0, lastAtIndex) if (lastAtIndex === -1 || textBeforeCursor.slice(lastAtIndex + 1).includes(' ')) { setIsOpen(false) setSearchText('') setMenuDismissed(false) // Reset dismissed flag when @ is removed } else { // Only open menu if it wasn't explicitly dismissed - if (!menuDismissed) { + if (!menuDismissed && (textBeforeLastAt.slice(-1) === ' ' || lastAtIndex === 0)) { setIsOpen(true) const searchStr = textBeforeCursor.slice(lastAtIndex + 1) setSearchText(searchStr)