Skip to content
Open
Changes from 1 commit
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
7 changes: 5 additions & 2 deletions apps/web/src/components/editor/media-panel/drag-overlay.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Upload, Plus, Image } from "lucide-react";
import { Upload } from "lucide-react";
import { Button } from "@/components/ui/button";

interface MediaDragOverlayProps {
Expand Down Expand Up @@ -27,7 +27,10 @@ export function MediaDragOverlay({

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={[
"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",
!isProcessing && onClick ? "cursor-pointer" : "cursor-default"
].join(" ")}
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.

>
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

Use a semantic button instead of a div for clickability (a11y + guidelines).

Current pattern attaches onClick to a non-interactive element, which violates the project guideline “Don’t use event handlers on non-interactive elements” and misses keyboard activation by default. Replace the root with a (with type and disabled), which also removes the need for extra key handlers.

-    <div
+    <button
+      type="button"
+      disabled={isProcessing || !onClick}
       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",
         !isProcessing && onClick ? "cursor-pointer" : "cursor-default"
       ].join(" ")}
       onClick={handleClick}
-    >
+    >
...
-    </div>
+    </button>
📝 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
<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={[
"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",
!isProcessing && onClick ? "cursor-pointer" : "cursor-default"
].join(" ")}
onClick={handleClick}
>
<button
type="button"
disabled={isProcessing || !onClick}
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",
!isProcessing && onClick ? "cursor-pointer" : "cursor-default"
].join(" ")}
onClick={handleClick}
>
{/* …existing children/content… */}
</button>

<div className="flex items-center justify-center">
Expand Down