Skip to content

The open-source app everyone uses to manage agents at work

fix: render mention autocomplete via portal to prevent overflow clipping

dotta0a32e3838ada
diff --git a/ui/src/components/MarkdownEditor.tsx b/ui/src/components/MarkdownEditor.tsx
index 342a74de54..68469761ba 100644
--- a/ui/src/components/MarkdownEditor.tsx
+++ b/ui/src/components/MarkdownEditor.tsx
@@ -8,6 +8,7 @@ import {
useState,
type DragEvent,
} from "react";
+import { createPortal } from "react-dom";
import {
CodeMirrorEditor,
MDXEditor,
@@ -82,6 +83,9 @@ interface MentionState {
query: string;
top: number;
left: number;
+ /** Viewport-relative coords for portal positioning */
+ viewportTop: number;
+ viewportLeft: number;
textNode: Text;
atPos: number;
endPos: number;
@@ -155,6 +159,8 @@ function detectMention(container: HTMLElement): MentionState | null {
query,
top: rect.bottom - containerRect.top,
left: rect.left - containerRect.left,
+ viewportTop: rect.bottom,
+ viewportLeft: rect.left,
textNode: textNode as Text,
atPos,
endPos: offset,
@@ -554,46 +560,48 @@ export const MarkdownEditor = forwardRef<MarkdownEditorRef, MarkdownEditorProps>
plugins={plugins}
/>
- {/* Mention dropdown */}
- {mentionActive && filteredMentions.length > 0 && (
- <div
- className="absolute z-50 min-w-[180px] max-h-[200px] overflow-y-auto rounded-md border border-border bg-popover shadow-md"
- style={{ top: mentionState.top + 4, left: mentionState.left }}
- >
- {filteredMentions.map((option, i) => (
- <button
- key={option.id}
- className={cn(
- "flex items-center gap-2 w-full px-3 py-1.5 text-sm text-left hover:bg-accent/50 transition-colors",
- i === mentionIndex && "bg-accent",
- )}
- onMouseDown={(e) => {
- e.preventDefault(); // prevent blur
- selectMention(option);
- }}
- onMouseEnter={() => setMentionIndex(i)}
- >
- {option.kind === "project" && option.projectId ? (
- <span
- className="inline-flex h-2 w-2 rounded-full border border-border/50"
- style={{ backgroundColor: option.projectColor ?? "#64748b" }}
- />
- ) : (
- <AgentIcon
- icon={option.agentIcon}
- className="h-3.5 w-3.5 shrink-0 text-muted-foreground"
- />
- )}
- <span>{option.name}</span>
- {option.kind === "project" && option.projectId && (
- <span className="ml-auto text-[10px] uppercase tracking-wide text-muted-foreground">
- Project
- </span>
- )}
- </button>
- ))}
- </div>
- )}
+ {/* Mention dropdown — rendered via portal so it isn't clipped by overflow containers */}
+ {mentionActive && filteredMentions.length > 0 &&
+ createPortal(
+ <div
+ className="fixed z-[9999] min-w-[180px] max-h-[200px] overflow-y-auto rounded-md border border-border bg-popover shadow-md"
+ style={{ top: mentionState.viewportTop + 4, left: mentionState.viewportLeft }}
+ >
+ {filteredMentions.map((option, i) => (
+ <button
+ key={option.id}
+ className={cn(
+ "flex items-center gap-2 w-full px-3 py-1.5 text-sm text-left hover:bg-accent/50 transition-colors",
+ i === mentionIndex && "bg-accent",
+ )}
+ onMouseDown={(e) => {
+ e.preventDefault(); // prevent blur
+ selectMention(option);
+ }}
+ onMouseEnter={() => setMentionIndex(i)}
+ >
+ {option.kind === "project" && option.projectId ? (
+ <span
+ className="inline-flex h-2 w-2 rounded-full border border-border/50"
+ style={{ backgroundColor: option.projectColor ?? "#64748b" }}
+ />
+ ) : (
+ <AgentIcon
+ icon={option.agentIcon}
+ className="h-3.5 w-3.5 shrink-0 text-muted-foreground"
+ />
+ )}
+ <span>{option.name}</span>
+ {option.kind === "project" && option.projectId && (
+ <span className="ml-auto text-[10px] uppercase tracking-wide text-muted-foreground">
+ Project
+ </span>
+ )}
+ </button>
+ ))}
+ </div>,
+ document.body,
+ )}
{isDragOver && canDropImage && (
<div