Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(editor): lift drag-drop overlay to outer container for better UX

Naiyuan Qing66cb5d924a25
diff --git a/packages/views/editor/content-editor.tsx b/packages/views/editor/content-editor.tsx
index 6383334668..b3a0850ad2 100644
--- a/packages/views/editor/content-editor.tsx
+++ b/packages/views/editor/content-editor.tsx
@@ -55,6 +55,8 @@ interface ContentEditorProps {
onSubmit?: () => void;
onBlur?: () => void;
onUploadFile?: (file: File) => Promise<UploadResult | null>;
+ /** When false, suppresses the internal drag-over overlay so the parent can render its own. Default true. */
+ showDropOverlay?: boolean;
}
interface ContentEditorRef {
@@ -80,6 +82,7 @@ const ContentEditor = forwardRef<ContentEditorRef, ContentEditorProps>(
onSubmit,
onBlur,
onUploadFile,
+ showDropOverlay = true,
},
ref,
) {
@@ -180,6 +183,7 @@ const ContentEditor = forwardRef<ContentEditorRef, ContentEditorProps>(
// Always clear drag overlay on any drop/dragend anywhere in the document
useEffect(() => {
+ if (!showDropOverlay) return;
const clear = () => setDragOver(false);
document.addEventListener("drop", clear);
document.addEventListener("dragend", clear);
@@ -187,7 +191,7 @@ const ContentEditor = forwardRef<ContentEditorRef, ContentEditorProps>(
document.removeEventListener("drop", clear);
document.removeEventListener("dragend", clear);
};
- }, []);
+ }, [showDropOverlay]);
// Readonly content update: when defaultValue changes and editor is readonly,
// re-set the content (e.g. after editing a comment, the readonly view updates)
@@ -222,39 +226,47 @@ const ContentEditor = forwardRef<ContentEditorRef, ContentEditorProps>(
return (
<div
- className={cn("relative min-h-full", dragOver && "editor-drag-over")}
- onDragEnter={(e) => {
- e.preventDefault();
- if (editable && e.dataTransfer.types.includes("Files"))
- setDragOver(true);
- }}
- onDragOver={(e) => {
- e.preventDefault();
- }}
- onDragLeave={(e) => {
- if (!e.currentTarget.contains(e.relatedTarget as Node))
- setDragOver(false);
- }}
- onDrop={(e) => {
- const alreadyHandled = e.nativeEvent.defaultPrevented;
- e.preventDefault();
- setDragOver(false);
- // Only upload if ProseMirror didn't already handle the drop.
- // When drop lands on the editor area, ProseMirror's handleDrop
- // processes it and calls preventDefault on the native event.
- // This fallback only fires when the overlay intercepted the drop.
- if (alreadyHandled) return;
- const files = e.dataTransfer?.files;
- if (files?.length && editor && onUploadFileRef.current) {
- const endPos = editor.state.doc.content.size;
- for (const file of Array.from(files)) {
- uploadAndInsertFile(editor, file, onUploadFileRef.current, endPos);
+ className={cn(
+ "relative min-h-full",
+ showDropOverlay && dragOver && "editor-drag-over",
+ )}
+ {...(showDropOverlay
+ ? {
+ onDragEnter: (e: React.DragEvent) => {
+ e.preventDefault();
+ if (editable && e.dataTransfer.types.includes("Files"))
+ setDragOver(true);
+ },
+ onDragOver: (e: React.DragEvent) => {
+ e.preventDefault();
+ },
+ onDragLeave: (e: React.DragEvent) => {
+ if (!e.currentTarget.contains(e.relatedTarget as Node))
+ setDragOver(false);
+ },
+ onDrop: (e: React.DragEvent) => {
+ const alreadyHandled = e.nativeEvent.defaultPrevented;
+ e.preventDefault();
+ setDragOver(false);
+ if (alreadyHandled) return;
+ const files = e.dataTransfer?.files;
+ if (files?.length && editor && onUploadFileRef.current) {
+ const endPos = editor.state.doc.content.size;
+ for (const file of Array.from(files)) {
+ uploadAndInsertFile(
+ editor,
+ file,
+ onUploadFileRef.current,
+ endPos,
+ );
+ }
+ }
+ },
}
- }
- }}
+ : {})}
>
<EditorContent editor={editor} />
- {dragOver && (
+ {showDropOverlay && dragOver && (
<div className="editor-drop-overlay">
<p>Drop files to upload</p>
</div>
diff --git a/packages/views/editor/file-drop-overlay.tsx b/packages/views/editor/file-drop-overlay.tsx
new file mode 100644
index 0000000000..a7500604a7
--- /dev/null
+++ b/packages/views/editor/file-drop-overlay.tsx
@@ -0,0 +1,7 @@
+function FileDropOverlay() {
+ return (
+ <div className="absolute inset-0 z-10 rounded-[inherit] border border-dashed border-brand/20 bg-brand/[0.02] pointer-events-none" />
+ );
+}
+
+export { FileDropOverlay };
diff --git a/packages/views/editor/index.ts b/packages/views/editor/index.ts
index f2da91eab5..a2e492c8b8 100644
--- a/packages/views/editor/index.ts
+++ b/packages/views/editor/index.ts
@@ -10,3 +10,5 @@ export {
} from "./title-editor";
export { copyMarkdown } from "./utils/clipboard";
export { ReadonlyContent } from "./readonly-content";
+export { useFileDropZone } from "./use-file-drop-zone";
+export { FileDropOverlay } from "./file-drop-overlay";
diff --git a/packages/views/editor/use-file-drop-zone.ts b/packages/views/editor/use-file-drop-zone.ts
new file mode 100644
index 0000000000..7636ab7240
--- /dev/null
+++ b/packages/views/editor/use-file-drop-zone.ts
@@ -0,0 +1,69 @@
+import { useState, useEffect, useCallback, useRef, type DragEvent } from "react";
+
+interface UseFileDropZoneOptions {
+ onDrop: (files: File[]) => void;
+ enabled?: boolean;
+}
+
+function useFileDropZone({ onDrop, enabled = true }: UseFileDropZoneOptions) {
+ const [isDragOver, setIsDragOver] = useState(false);
+ const onDropRef = useRef(onDrop);
+ onDropRef.current = onDrop;
+
+ // Clear on any document-level drop or dragend (e.g. user drops outside the zone)
+ useEffect(() => {
+ if (!enabled) return;
+ const clear = () => setIsDragOver(false);
+ document.addEventListener("drop", clear);
+ document.addEventListener("dragend", clear);
+ return () => {
+ document.removeEventListener("drop", clear);
+ document.removeEventListener("dragend", clear);
+ };
+ }, [enabled]);
+
+ const handleDragEnter = useCallback(
+ (e: DragEvent) => {
+ e.preventDefault();
+ if (enabled && e.dataTransfer.types.includes("Files")) {
+ setIsDragOver(true);
+ }
+ },
+ [enabled],
+ );
+
+ const handleDragOver = useCallback((e: DragEvent) => {
+ e.preventDefault();
+ }, []);
+
+ const handleDragLeave = useCallback((e: DragEvent) => {
+ if (!e.currentTarget.contains(e.relatedTarget as Node)) {
+ setIsDragOver(false);
+ }
+ }, []);
+
+ const handleDrop = useCallback(
+ (e: DragEvent) => {
+ const alreadyHandled = e.nativeEvent.defaultPrevented;
+ e.preventDefault();
+ setIsDragOver(false);
+ if (alreadyHandled || !enabled) return;
+ const files = e.dataTransfer?.files;
+ if (files?.length) {
+ onDropRef.current(Array.from(files));
+ }
+ },
+ [enabled],
+ );
+
+ const dropZoneProps = {
+ onDragEnter: handleDragEnter,
+ onDragOver: handleDragOver,
+ onDragLeave: handleDragLeave,
+ onDrop: handleDrop,
+ };
+
+ return { isDragOver: enabled && isDragOver, dropZoneProps };
+}
+
+export { useFileDropZone };
diff --git a/packages/views/issues/components/comment-card.tsx b/packages/views/issues/components/comment-card.tsx
index 3f7769344c..4732ef2a45 100644
--- a/packages/views/issues/components/comment-card.tsx
+++ b/packages/views/issues/components/comment-card.tsx
@@ -31,6 +31,8 @@ import { cn } from "@multica/ui/lib/utils";
import { useActorName } from "@multica/core/workspace/hooks";
import { timeAgo } from "@multica/core/utils";
import { ContentEditor, type ContentEditorRef, copyMarkdown, ReadonlyContent } from "../../editor";
+import { useFileDropZone } from "../../editor/use-file-drop-zone";
+import { FileDropOverlay } from "../../editor/file-drop-overlay";
import { FileUploadButton } from "@multica/ui/components/common/file-upload-button";
import { useFileUpload } from "@multica/core/hooks/use-file-upload";
import { api } from "@multica/core/api";
@@ -115,6 +117,10 @@ function CommentRow({
const editEditorRef = useRef<ContentEditorRef>(null);
const cancelledRef = useRef(false);
const { uploadWithToast } = useFileUpload(api);
+ const { isDragOver, dropZoneProps } = useFileDropZone({
+ onDrop: (files) => files.forEach((f) => editEditorRef.current?.uploadFile(f)),
+ enabled: editing,
+ });
const isOwn = entry.actor_type === "member" && entry.actor_id === currentUserId;
const isTemp = entry.id.startsWith("temp-");
@@ -221,7 +227,8 @@ function CommentRow({
{editing ? (
<div
- className="mt-1.5 pl-8"
+ {...dropZoneProps}
+ className="relative mt-1.5 pl-8"
onKeyDown={(e) => { if (e.key === "Escape") cancelEdit(); }}
>
<div className="max-h-48 overflow-y-auto text-sm leading-relaxed">
@@ -231,6 +238,7 @@ function CommentRow({
placeholder="Edit comment..."
onSubmit={saveEdit}
onUploadFile={(file) => uploadWithToast(file, { issueId })}
+ showDropOverlay={false}
debounceMs={100}
/>
</div>
@@ -244,6 +252,7 @@ function CommentRow({
<Button size="sm" variant="outline" onClick={saveEdit}>Save</Button>
</div>
</div>
+ {isDragOver && <FileDropOverlay />}
</div>
) : (
<>
@@ -287,6 +296,10 @@ function CommentCard({
const [editing, setEditing] = useState(false);
const editEditorRef = useRef<ContentEditorRef>(null);
const cancelledRef = useRef(false);
+ const { isDragOver: parentDragOver, dropZoneProps: parentDropZoneProps } = useFileDropZone({
+ onDrop: (files) => files.forEach((f) => editEditorRef.current?.uploadFile(f)),
+ enabled: editing,
+ });
const isOwn = entry.actor_type === "member" && entry.actor_id === currentUserId;
const isTemp = entry.id.startsWith("temp-");
@@ -431,7 +444,8 @@ function CommentCard({
<div className="px-4 pb-3">
{editing ? (
<div
- className="pl-10"
+ {...parentDropZoneProps}
+ className="relative pl-10"
onKeyDown={(e) => { if (e.key === "Escape") cancelEdit(); }}
>
<div className="max-h-48 overflow-y-auto text-sm leading-relaxed">
@@ -441,6 +455,7 @@ function CommentCard({
placeholder="Edit comment..."
onSubmit={saveEdit}
onUploadFile={(file) => uploadWithToast(file, { issueId })}
+ showDropOverlay={false}
debounceMs={100}
/>
</div>
@@ -454,6 +469,7 @@ function CommentCard({
<Button size="sm" variant="outline" onClick={saveEdit}>Save</Button>
</div>
</div>
+ {parentDragOver && <FileDropOverlay />}
</div>
) : (
<>
diff --git a/packages/views/issues/components/comment-input.tsx b/packages/views/issues/components/comment-input.tsx
index 83639b0b30..88090c1c82 100644
--- a/packages/views/issues/components/comment-input.tsx
+++ b/packages/views/issues/components/comment-input.tsx
@@ -3,7 +3,10 @@
import { useRef, useState } from "react";
import { ArrowUp, Loader2 } from "lucide-react";
import { Button } from "@multica/ui/components/ui/button";
+import { cn } from "@multica/ui/lib/utils";
import { ContentEditor, type ContentEditorRef } from "../../editor";
+import { useFileDropZone } from "../../editor/use-file-drop-zone";
+import { FileDropOverlay } from "../../editor/file-drop-overlay";
import { FileUploadButton } from "@multica/ui/components/common/file-upload-button";
import { useFileUpload } from "@multica/core/hooks/use-file-upload";
import { api } from "@multica/core/api";
@@ -19,6 +22,9 @@ function CommentInput({ issueId, onSubmit }: CommentInputProps) {
const [submitting, setSubmitting] = useState(false);
const [attachmentIds, setAttachmentIds] = useState<string[]>([]);
const { uploadWithToast } = useFileUpload(api);
+ const { isDragOver, dropZoneProps } = useFileDropZone({
+ onDrop: (files) => files.forEach((f) => editorRef.current?.uploadFile(f)),
+ });
const handleUpload = async (file: File) => {
const result = await uploadWithToast(file, { issueId });
@@ -43,7 +49,13 @@ function CommentInput({ issueId, onSubmit }: CommentInputProps) {
};
return (
- <div className="relative flex max-h-56 flex-col rounded-lg bg-card pb-8 ring-1 ring-border">
+ <div
+ {...dropZoneProps}
+ className={cn(
+ "relative flex max-h-56 flex-col rounded-lg bg-card pb-8 ring-1 ring-border",
+ isDragOver && "ring-brand/30",
+ )}
+ >
<div className="flex-1 min-h-0 overflow-y-auto px-3 py-2">
<ContentEditor
ref={editorRef}
@@ -51,6 +63,7 @@ function CommentInput({ issueId, onSubmit }: CommentInputProps) {
onUpdate={(md) => setIsEmpty(!md.trim())}
onSubmit={handleSubmit}
onUploadFile={handleUpload}
+ showDropOverlay={false}
debounceMs={100}
/>
</div>
@@ -71,6 +84,7 @@ function CommentInput({ issueId, onSubmit }: CommentInputProps) {
)}
</Button>
</div>
+ {isDragOver && <FileDropOverlay />}
</div>
);
}
diff --git a/packages/views/issues/components/issue-detail.tsx b/packages/views/issues/components/issue-detail.tsx
index 904afb13fe..89e6dbc83d 100644
--- a/packages/views/issues/components/issue-detail.tsx
+++ b/packages/views/issues/components/issue-detail.tsx
@@ -42,6 +42,8 @@ import {
} from "@multica/ui/components/ui/dropdown-menu";
import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from "@multica/ui/components/ui/resizable";
import { ContentEditor, type ContentEditorRef } from "../../editor";
+import { useFileDropZone } from "../../editor/use-file-drop-zone";
+import { FileDropOverlay } from "../../editor/file-drop-overlay";
import { FileUploadButton } from "@multica/ui/components/common/file-upload-button";
import { TitleEditor } from "../../editor";
import {
@@ -297,6 +299,9 @@ export function IssueDetail({ issueId, onDelete, defaultSidebarOpen = true, layo
);
const descEditorRef = useRef<ContentEditorRef>(null);
+ const { isDragOver: descDragOver, dropZoneProps: descDropZoneProps } = useFileDropZone({
+ onDrop: (files) => files.forEach((f) => descEditorRef.current?.uploadFile(f)),
+ });
// Description uploads don't pass issueId — the URL lives in the markdown.
// This avoids stale attachment records when users delete images from the editor.
const handleDescriptionUpload = useCallback(
@@ -702,35 +707,38 @@ export function IssueDetail({ issueId, onDelete, defaultSidebarOpen = true, layo
</AppLink>
)}
- <ContentEditor
- ref={descEditorRef}
- key={id}
- defaultValue={issue.description || ""}
- placeholder="Add description..."
- onUpdate={(md) => handleUpdateField({ description: md || undefined })}
- onUploadFile={handleDescriptionUpload}
- debounceMs={1500}
- className="mt-5"
- />
+ <div {...descDropZoneProps} className="relative mt-5 rounded-lg">
+ <ContentEditor
+ ref={descEditorRef}
+ key={id}
+ defaultValue={issue.description || ""}
+ placeholder="Add description..."
+ onUpdate={(md) => handleUpdateField({ description: md || undefined })}
+ onUploadFile={handleDescriptionUpload}
+ showDropOverlay={false}
+ debounceMs={1500}
+ />
- <div className="flex items-center gap-1 mt-3">
- {reactionsLoading ? (
- <div className="flex items-center gap-1">
- <Skeleton className="h-7 w-14 rounded-full" />
- <Skeleton className="h-7 w-14 rounded-full" />
- </div>
- ) : (
- <ReactionBar
- reactions={issueReactions}
- currentUserId={user?.id}
- onToggle={handleToggleIssueReaction}
- getActorName={getActorName}
+ <div className="flex items-center gap-1 mt-3">
+ {reactionsLoading ? (
+ <div className="flex items-center gap-1">
+ <Skeleton className="h-7 w-14 rounded-full" />
+ <Skeleton className="h-7 w-14 rounded-full" />
+ </div>
+ ) : (
+ <ReactionBar
+ reactions={issueReactions}
+ currentUserId={user?.id}
+ onToggle={handleToggleIssueReaction}
+ getActorName={getActorName}
+ />
+ )}
+ <FileUploadButton
+ size="sm"
+ onSelect={(file) => descEditorRef.current?.uploadFile(file)}
/>
- )}
- <FileUploadButton
- size="sm"
- onSelect={(file) => descEditorRef.current?.uploadFile(file)}
- />
+ </div>
+ {descDragOver && <FileDropOverlay />}
</div>
{/* Sub-issues — Linear-style */}
diff --git a/packages/views/issues/components/reply-input.tsx b/packages/views/issues/components/reply-input.tsx
index ffb6e548bd..4a4bc96118 100644
--- a/packages/views/issues/components/reply-input.tsx
+++ b/packages/views/issues/components/reply-input.tsx
@@ -3,6 +3,8 @@
import { useRef, useState, useEffect } from "react";
import { ArrowUp, Loader2 } from "lucide-react";
import { ContentEditor, type ContentEditorRef } from "../../editor";
+import { useFileDropZone } from "../../editor/use-file-drop-zone";
+import { FileDropOverlay } from "../../editor/file-drop-overlay";
import { FileUploadButton } from "@multica/ui/components/common/file-upload-button";
import { ActorAvatar } from "../../common/actor-avatar";
import { useFileUpload } from "@multica/core/hooks/use-file-upload";
@@ -41,6 +43,9 @@ function ReplyInput({
const [submitting, setSubmitting] = useState(false);
const [attachmentIds, setAttachmentIds] = useState<string[]>([]);
const { uploadWithToast } = useFileUpload(api);
+ const { isDragOver, dropZoneProps } = useFileDropZone({
+ onDrop: (files) => files.forEach((f) => editorRef.current?.uploadFile(f)),
+ });
useEffect(() => {
const el = measureRef.current;
@@ -86,6 +91,7 @@ function ReplyInput({
className="mt-0.5 shrink-0"
/>
<div
+ {...dropZoneProps}
className={cn(
"relative min-w-0 flex-1 flex flex-col",
size === "sm" ? "max-h-40" : "max-h-56",
@@ -100,6 +106,7 @@ function ReplyInput({
onUpdate={(md) => setIsEmpty(!md.trim())}
onSubmit={handleSubmit}
onUploadFile={handleUpload}
+ showDropOverlay={false}
debounceMs={100}
/>
</div>
@@ -122,6 +129,7 @@ function ReplyInput({
)}
</button>
</div>
+ {isDragOver && <FileDropOverlay />}
</div>
</div>
);
diff --git a/packages/views/modals/create-issue.tsx b/packages/views/modals/create-issue.tsx
index e52be91ab4..65a977216e 100644
--- a/packages/views/modals/create-issue.tsx
+++ b/packages/views/modals/create-issue.tsx
@@ -14,6 +14,8 @@ import {
import { Tooltip, TooltipTrigger, TooltipContent } from "@multica/ui/components/ui/tooltip";
import { Button } from "@multica/ui/components/ui/button";
import { ContentEditor, type ContentEditorRef } from "../editor";
+import { useFileDropZone } from "../editor/use-file-drop-zone";
+import { FileDropOverlay } from "../editor/file-drop-overlay";
import { TitleEditor } from "../editor";
import { StatusIcon, StatusPicker, PriorityPicker, AssigneePicker, DueDatePicker } from "../issues/components";
import { ProjectPicker } from "../projects/components/project-picker";
@@ -62,6 +64,9 @@ export function CreateIssueModal({ onClose, data }: { onClose: () => void; data?
const [title, setTitle] = useState(draft.title);
const descEditorRef = useRef<ContentEditorRef>(null);
+ const { isDragOver: descDragOver, dropZoneProps: descDropZoneProps } = useFileDropZone({
+ onDrop: (files) => files.forEach((f) => descEditorRef.current?.uploadFile(f)),
+ });
const [status, setStatus] = useState<IssueStatus>((data?.status as IssueStatus) || draft.status);
const [priority, setPriority] = useState<IssuePriority>(draft.priority);
const [submitting, setSubmitting] = useState(false);
@@ -215,15 +220,17 @@ export function CreateIssueModal({ onClose, data }: { onClose: () => void; data?
</div>
{/* Description — takes remaining space */}
- <div className="flex-1 min-h-0 overflow-y-auto px-5">
+ <div {...descDropZoneProps} className="relative flex-1 min-h-0 overflow-y-auto px-5">
<ContentEditor
ref={descEditorRef}
defaultValue={draft.description}
placeholder="Add description..."
onUpdate={(md) => setDraft({ description: md })}
onUploadFile={handleUpload}
+ showDropOverlay={false}
debounceMs={500}
/>
+ {descDragOver && <FileDropOverlay />}
</div>
{/* Property toolbar */}