Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🌵 fix: Align Mention Empty Result Behavior With Skills Command (#13928)

Oliver777int6934d07066f8
diff --git a/client/src/components/Chat/Input/Mention.tsx b/client/src/components/Chat/Input/Mention.tsx
index c2d352a4e6..464a0afc87 100644
--- a/client/src/components/Chat/Input/Mention.tsx
+++ b/client/src/components/Chat/Input/Mention.tsx
@@ -128,6 +128,10 @@ function MentionContent({
}
}, [open, options]);
+ useEffect(() => {
+ setActiveIndex((prev) => Math.min(prev, Math.max(matches.length - 1, 0)));
+ }, [matches.length]);
+
useEffect(() => {
return () => {
if (timeoutRef.current) {
@@ -191,10 +195,25 @@ function MentionContent({
textAreaRef.current?.focus();
}
if (e.key === 'ArrowDown') {
+ if (matches.length === 0) {
+ return;
+ }
setActiveIndex((prevIndex) => (prevIndex + 1) % matches.length);
} else if (e.key === 'ArrowUp') {
+ if (matches.length === 0) {
+ return;
+ }
setActiveIndex((prevIndex) => (prevIndex - 1 + matches.length) % matches.length);
} else if (e.key === 'Enter' || e.key === 'Tab') {
+ if (matches.length === 0) {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ }
+ setOpen(false);
+ setShowPopover(false);
+ textAreaRef.current?.focus();
+ return;
+ }
const mentionOption = matches[activeIndex] as MentionOption | undefined;
if (mentionOption?.type === 'endpoint') {
e.preventDefault();