Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions apps/web/src/components/editor/media-panel/drag-overlay.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Upload, Plus, Image } from "lucide-react";
import { Upload } from "lucide-react";
import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";


interface MediaDragOverlayProps {
isVisible: boolean;
Expand All @@ -24,11 +26,27 @@ export function MediaDragOverlay({
e.stopPropagation();
onClick();
};
const isClickable = !isProcessing && !!onClick;

return (
<div
className="flex flex-col items-center justify-center gap-4 h-full text-center rounded-lg bg-foreground/5 hover:bg-foreground/10 transition-all duration-200 p-8"
className={cn(
"flex flex-col items-center justify-center gap-4 h-full text-center rounded-lg bg-foreground/5 hover:bg-foreground/10 transition-all duration-200 p-8",
isClickable ? "cursor-pointer" : "cursor-default"
)}
onClick={handleClick}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Don't attach handlers when not interactive.

Attaching onClick to a non-interactive element violates our JSX guideline. Only bind the handler when clickable.

-      onClick={handleClick}
+      onClick={isClickable ? handleClick : undefined}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
onClick={handleClick}
onClick={isClickable ? handleClick : undefined}
🤖 Prompt for AI Agents
In apps/web/src/components/editor/media-panel/drag-overlay.tsx around line 37,
the JSX currently attaches onClick={handleClick} unconditionally; update the
component so event handlers are only bound when the element is actually
interactive: either conditionally include the onClick prop (e.g. spread an
interactiveProps object only when clickable/interactive is true) or convert the
element to a semantic interactive element (button) and add appropriate
accessibility attributes (role, tabIndex, aria-*) if it must remain a non-button
but interactive; ensure no onClick is attached when the overlay is
non-interactive.


role={isClickable ? "button" : undefined}
tabIndex={isClickable ? 0 : undefined}
aria-disabled={isProcessing || !onClick || undefined}
// Without onKeyDown: only mouse users can trigger it. With onKeyDown; also keyboard users.
onKeyDown={(e) => {
if (!isClickable) return;
if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
onClick?.();
}
}}
>
<div className="flex items-center justify-center">
<Upload className="h-10 w-10 text-foreground" />
Expand Down