-
Couldn't load subscription status.
- Fork 4k
fix(media-overlay): add cursor-pointer when clickable #583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@iyiolacak is attempting to deploy a commit to the OpenCut OSS Team on Vercel. A member of the Team first needs to authorize it. |
👷 Deploy request for appcut pending review.Visit the deploys page to approve it
|
WalkthroughAdds interactivity and accessibility to the media-panel drag overlay: trims unused icon imports, introduces a computed Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Overlay as DragOverlay
participant App as onClickHandler
Note over Overlay: state: isProcessing?, onClick?
User->>Overlay: mouse click
alt isClickable (not processing && onClick present)
Overlay->>App: call onClick()
App-->>Overlay: result
else not clickable
Overlay-->>User: ignore click
end
User->>Overlay: keydown (Enter/Space)
alt isClickable
Overlay->>App: call onClick()
App-->>Overlay: result
else
Overlay-->>User: ignore key
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (4)
apps/web/src/components/editor/media-panel/drag-overlay.tsx (4)
1-2: Remove unused import.
Buttonis imported but not used.import { Upload } from "lucide-react"; -import { Button } from "@/components/ui/button";
36-38: Mark decorative icon as hidden from screen readers.There’s descriptive text below; hide the SVG from AT to avoid redundant announcements.
- <Upload className="h-10 w-10 text-foreground" /> + <Upload aria-hidden="true" className="h-10 w-10 text-foreground" />
21-26: Prefer type-only import overReact.MouseEventnamespace reference.Keeps to modern TS patterns and avoids relying on a global React namespace.
+import type { MouseEvent } from "react"; ... - const handleClick = (e: React.MouseEvent) => { + const handleClick = (e: MouseEvent) => {If you adopt the refactor, you can narrow to
MouseEvent<HTMLButtonElement>.
52-54: Clamp progress to [0, 100] to prevent bar overflow.Protects against out-of-range values without changing behavior for valid inputs.
- style={{ width: `${progress}%` }} + style={{ width: `${Math.max(0, Math.min(100, progress))}%` }}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
apps/web/src/components/editor/media-panel/drag-overlay.tsx(2 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{jsx,tsx}: Don't useaccessKeyattribute on any HTML element.
Don't setaria-hidden="true"on focusable elements.
Don't add ARIA roles, states, and properties to elements that don't support them.
Don't use distracting elements like<marquee>or<blink>.
Only use thescopeprop on<th>elements.
Don't assign non-interactive ARIA roles to interactive HTML elements.
Make sure label elements have text content and are associated with an input.
Don't assign interactive ARIA roles to non-interactive HTML elements.
Don't assigntabIndexto non-interactive HTML elements.
Don't use positive integers fortabIndexproperty.
Don't include "image", "picture", or "photo" in img alt prop.
Don't use explicit role property that's the same as the implicit/default role.
Make static elements with click handlers use a valid role attribute.
Always include atitleelement for SVG elements.
Give all elements requiring alt text meaningful information for screen readers.
Make sure anchors have content that's accessible to screen readers.
AssigntabIndexto non-interactive HTML elements witharia-activedescendant.
Include all required ARIA attributes for elements with ARIA roles.
Make sure ARIA properties are valid for the element's supported roles.
Always include atypeattribute for button elements.
Make elements with interactive roles and handlers focusable.
Give heading elements content that's accessible to screen readers (not hidden witharia-hidden).
Always include alangattribute on the html element.
Always include atitleattribute for iframe elements.
AccompanyonClickwith at least one of:onKeyUp,onKeyDown, oronKeyPress.
AccompanyonMouseOver/onMouseOutwithonFocus/onBlur.
Include caption tracks for audio and video elements.
Use semantic elements instead of role attributes in JSX.
Make sure all anchors are valid and navigable.
Ensure all ARIA properties (aria-*) are valid.
Use valid, non-abstract ARIA roles for elements with...
Files:
apps/web/src/components/editor/media-panel/drag-overlay.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Don't use TypeScript enums.
Don't export imported variables.
Don't add type annotations to variables, parameters, and class properties that are initialized with literal expressions.
Don't use TypeScript namespaces.
Don't use non-null assertions with the!postfix operator.
Don't use parameter properties in class constructors.
Don't use user-defined types.
Useas constinstead of literal types and type annotations.
Use eitherT[]orArray<T>consistently.
Initialize each enum member value explicitly.
Useexport typefor types.
Useimport typefor types.
Make sure all enum members are literal values.
Don't use TypeScript const enum.
Don't declare empty interfaces.
Don't let variables evolve into any type through reassignments.
Don't use the any type.
Don't misuse the non-null assertion operator (!) in TypeScript files.
Don't use implicit any type on variable declarations.
Don't merge interfaces and classes unsafely.
Don't use overload signatures that aren't next to each other.
Use the namespace keyword instead of the module keyword to declare TypeScript namespaces.
Don't use empty type parameters in type aliases and interfaces.
Don't use any or unknown as type constraints.
Don't use the TypeScript directive @ts-ignore.
Use consistent accessibility modifiers on class properties and methods.
Use function types instead of object types with call signatures.
Don't use void type outside of generic or return types.
**/*.{ts,tsx}: Don't use primitive type aliases or misleading types
Don't use the TypeScript directive @ts-ignore
Don't use TypeScript enums
Use either T[] or Array consistently
Don't use the any type
Files:
apps/web/src/components/editor/media-panel/drag-overlay.tsx
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{js,jsx,ts,tsx}: Don't use the return value of React.render.
Don't use consecutive spaces in regular expression literals.
Don't use theargumentsobject.
Don't use primitive type aliases or misleading types.
Don't use the comma operator.
Don't write functions that exceed a given Cognitive Complexity score.
Don't use unnecessary boolean casts.
Don't use unnecessary callbacks with flatMap.
Use for...of statements instead of Array.forEach.
Don't create classes that only have static members (like a static namespace).
Don't use this and super in static contexts.
Don't use unnecessary catch clauses.
Don't use unnecessary constructors.
Don't use unnecessary continue statements.
Don't export empty modules that don't change anything.
Don't use unnecessary escape sequences in regular expression literals.
Don't use unnecessary labels.
Don't use unnecessary nested block statements.
Don't rename imports, exports, and destructured assignments to the same name.
Don't use unnecessary string or template literal concatenation.
Don't use String.raw in template literals when there are no escape sequences.
Don't use useless case statements in switch statements.
Don't use ternary operators when simpler alternatives exist.
Don't use uselessthisaliasing.
Don't initialize variables to undefined.
Don't use the void operators (they're not familiar).
Use arrow functions instead of function expressions.
Use Date.now() to get milliseconds since the Unix Epoch.
Use .flatMap() instead of map().flat() when possible.
Use literal property access instead of computed property access.
Don't use parseInt() or Number.parseInt() when binary, octal, or hexadecimal literals work.
Use concise optional chaining instead of chained logical expressions.
Use regular expression literals instead of the RegExp constructor when possible.
Don't use number literal object member names that aren't base 10 or use underscore separators.
Remove redundant terms from logical expressions.
Use while loops instead of...
Files:
apps/web/src/components/editor/media-panel/drag-overlay.tsx
**/*.{tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{tsx,jsx}: Always include a title element for icons unless there's text beside the icon
Always include a type attribute for button elements
Accompany onClick with at least one of: onKeyUp, onKeyDown, or onKeyPress
Accompany onMouseOver/onMouseOut with onFocus/onBlur
Don't import React itself
Don't define React components inside other components
Don't use both children and dangerouslySetInnerHTML on the same element
Don't insert comments as text nodes
Use <>...</> instead of ...
Files:
apps/web/src/components/editor/media-panel/drag-overlay.tsx
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{ts,tsx,js,jsx}: Don't use the comma operator
Use for...of statements instead of Array.forEach
Don't initialize variables to undefined
Use .flatMap() instead of map().flat() when possible
Don't assign a value to itself
Avoid unused imports and variables
Don't use await inside loops
Don't hardcode sensitive data like API keys and tokens
Don't use the delete operator
Don't use global eval()
Use String.slice() instead of String.substr() and String.substring()
Don't use else blocks when the if block breaks early
Put default function parameters and optional function parameters last
Use new when throwing an error
Use String.trimStart() and String.trimEnd() over String.trimLeft() and String.trimRight()
Files:
apps/web/src/components/editor/media-panel/drag-overlay.tsx
🔇 Additional comments (1)
apps/web/src/components/editor/media-panel/drag-overlay.tsx (1)
30-33: Conditional cursor logic is correct—nice fix.Applying cursor-pointer only when clickable (not processing and handler exists) addresses the bug without side effects.
| <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} | ||
| > |
There was a problem hiding this comment.
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.
| <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> |
…prove a11y - Use cn() instead of manual array.join for cleaner class handling - Apply cursor-pointer only when overlay is clickable (&& onClick) - Add role=button, tabIndex, aria-disabled, and onKeyDown for keyboard accessibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (1)
apps/web/src/components/editor/media-panel/drag-overlay.tsx (1)
39-49: Use a semantic for clickability (a11y + guidelines).Per retrieved learnings (“Don’t use event handlers on non-interactive elements” and “Make interactive roles focusable”), prefer a native button and its disabled state over div+role+key handlers. This removes custom keyboard logic and aligns with expected semantics.
Apply:
- <div + <button + type="button" 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" + "flex flex-col items-center justify-center gap-4 h-full text-center rounded-lg bg-foreground/5 transition-all duration-200 p-8", + isClickable ? "hover:bg-foreground/10 cursor-pointer" : "cursor-default" )} - onClick={handleClick} - - 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?.(); - } - }} + onClick={handleClick} + disabled={!isClickable} > ... - </div> + </button>
🧹 Nitpick comments (3)
apps/web/src/components/editor/media-panel/drag-overlay.tsx (3)
33-36: Gate hover affordance to clickable state.Avoid suggesting interactivity when disabled by applying hover styles only when clickable.
Apply:
- 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" - )} + className={cn( + "flex flex-col items-center justify-center gap-4 h-full text-center rounded-lg bg-foreground/5 transition-all duration-200 p-8", + isClickable ? "hover:bg-foreground/10 cursor-pointer" : "cursor-default" + )}
23-24: Type the event handlers without importing React runtime.Avoid the React namespace in types and implicit any on the key handler.
+import type { KeyboardEvent, MouseEvent } from "react"; ... - const handleClick = (e: React.MouseEvent) => { + const handleClick = (e: MouseEvent) => { if (isProcessing || !onClick) return; e.preventDefault(); e.stopPropagation(); onClick(); }; ... - onKeyDown={(e) => { + onKeyDown={(e: KeyboardEvent<HTMLDivElement>) => {If you adopt the refactor above, you can drop onKeyDown entirely.
Also applies to: 43-49
63-71: Clamp progress to [0, 100] to avoid layout overflow.Defensive clamp prevents accidental over/underflow widths.
- const isClickable = !isProcessing && !!onClick; + const isClickable = !isProcessing && !!onClick; + const safeProgress = Math.min(100, Math.max(0, progress)); ... - style={{ width: `${progress}%` }} + style={{ width: `${safeProgress}%` }}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
apps/web/src/components/editor/media-panel/drag-overlay.tsx(2 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{jsx,tsx}: Don't useaccessKeyattribute on any HTML element.
Don't setaria-hidden="true"on focusable elements.
Don't add ARIA roles, states, and properties to elements that don't support them.
Don't use distracting elements like<marquee>or<blink>.
Only use thescopeprop on<th>elements.
Don't assign non-interactive ARIA roles to interactive HTML elements.
Make sure label elements have text content and are associated with an input.
Don't assign interactive ARIA roles to non-interactive HTML elements.
Don't assigntabIndexto non-interactive HTML elements.
Don't use positive integers fortabIndexproperty.
Don't include "image", "picture", or "photo" in img alt prop.
Don't use explicit role property that's the same as the implicit/default role.
Make static elements with click handlers use a valid role attribute.
Always include atitleelement for SVG elements.
Give all elements requiring alt text meaningful information for screen readers.
Make sure anchors have content that's accessible to screen readers.
AssigntabIndexto non-interactive HTML elements witharia-activedescendant.
Include all required ARIA attributes for elements with ARIA roles.
Make sure ARIA properties are valid for the element's supported roles.
Always include atypeattribute for button elements.
Make elements with interactive roles and handlers focusable.
Give heading elements content that's accessible to screen readers (not hidden witharia-hidden).
Always include alangattribute on the html element.
Always include atitleattribute for iframe elements.
AccompanyonClickwith at least one of:onKeyUp,onKeyDown, oronKeyPress.
AccompanyonMouseOver/onMouseOutwithonFocus/onBlur.
Include caption tracks for audio and video elements.
Use semantic elements instead of role attributes in JSX.
Make sure all anchors are valid and navigable.
Ensure all ARIA properties (aria-*) are valid.
Use valid, non-abstract ARIA roles for elements with...
Files:
apps/web/src/components/editor/media-panel/drag-overlay.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Don't use TypeScript enums.
Don't export imported variables.
Don't add type annotations to variables, parameters, and class properties that are initialized with literal expressions.
Don't use TypeScript namespaces.
Don't use non-null assertions with the!postfix operator.
Don't use parameter properties in class constructors.
Don't use user-defined types.
Useas constinstead of literal types and type annotations.
Use eitherT[]orArray<T>consistently.
Initialize each enum member value explicitly.
Useexport typefor types.
Useimport typefor types.
Make sure all enum members are literal values.
Don't use TypeScript const enum.
Don't declare empty interfaces.
Don't let variables evolve into any type through reassignments.
Don't use the any type.
Don't misuse the non-null assertion operator (!) in TypeScript files.
Don't use implicit any type on variable declarations.
Don't merge interfaces and classes unsafely.
Don't use overload signatures that aren't next to each other.
Use the namespace keyword instead of the module keyword to declare TypeScript namespaces.
Don't use empty type parameters in type aliases and interfaces.
Don't use any or unknown as type constraints.
Don't use the TypeScript directive @ts-ignore.
Use consistent accessibility modifiers on class properties and methods.
Use function types instead of object types with call signatures.
Don't use void type outside of generic or return types.
**/*.{ts,tsx}: Don't use primitive type aliases or misleading types
Don't use the TypeScript directive @ts-ignore
Don't use TypeScript enums
Use either T[] or Array consistently
Don't use the any type
Files:
apps/web/src/components/editor/media-panel/drag-overlay.tsx
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{js,jsx,ts,tsx}: Don't use the return value of React.render.
Don't use consecutive spaces in regular expression literals.
Don't use theargumentsobject.
Don't use primitive type aliases or misleading types.
Don't use the comma operator.
Don't write functions that exceed a given Cognitive Complexity score.
Don't use unnecessary boolean casts.
Don't use unnecessary callbacks with flatMap.
Use for...of statements instead of Array.forEach.
Don't create classes that only have static members (like a static namespace).
Don't use this and super in static contexts.
Don't use unnecessary catch clauses.
Don't use unnecessary constructors.
Don't use unnecessary continue statements.
Don't export empty modules that don't change anything.
Don't use unnecessary escape sequences in regular expression literals.
Don't use unnecessary labels.
Don't use unnecessary nested block statements.
Don't rename imports, exports, and destructured assignments to the same name.
Don't use unnecessary string or template literal concatenation.
Don't use String.raw in template literals when there are no escape sequences.
Don't use useless case statements in switch statements.
Don't use ternary operators when simpler alternatives exist.
Don't use uselessthisaliasing.
Don't initialize variables to undefined.
Don't use the void operators (they're not familiar).
Use arrow functions instead of function expressions.
Use Date.now() to get milliseconds since the Unix Epoch.
Use .flatMap() instead of map().flat() when possible.
Use literal property access instead of computed property access.
Don't use parseInt() or Number.parseInt() when binary, octal, or hexadecimal literals work.
Use concise optional chaining instead of chained logical expressions.
Use regular expression literals instead of the RegExp constructor when possible.
Don't use number literal object member names that aren't base 10 or use underscore separators.
Remove redundant terms from logical expressions.
Use while loops instead of...
Files:
apps/web/src/components/editor/media-panel/drag-overlay.tsx
**/*.{tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{tsx,jsx}: Always include a title element for icons unless there's text beside the icon
Always include a type attribute for button elements
Accompany onClick with at least one of: onKeyUp, onKeyDown, or onKeyPress
Accompany onMouseOver/onMouseOut with onFocus/onBlur
Don't import React itself
Don't define React components inside other components
Don't use both children and dangerouslySetInnerHTML on the same element
Don't insert comments as text nodes
Use <>...</> instead of ...
Files:
apps/web/src/components/editor/media-panel/drag-overlay.tsx
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{ts,tsx,js,jsx}: Don't use the comma operator
Use for...of statements instead of Array.forEach
Don't initialize variables to undefined
Use .flatMap() instead of map().flat() when possible
Don't assign a value to itself
Avoid unused imports and variables
Don't use await inside loops
Don't hardcode sensitive data like API keys and tokens
Don't use the delete operator
Don't use global eval()
Use String.slice() instead of String.substr() and String.substring()
Don't use else blocks when the if block breaks early
Put default function parameters and optional function parameters last
Use new when throwing an error
Use String.trimStart() and String.trimEnd() over String.trimLeft() and String.trimRight()
Files:
apps/web/src/components/editor/media-panel/drag-overlay.tsx
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
PR: OpenCut-app/OpenCut#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-09T09:03:49.797Z
Learning: Applies to **/*.{jsx,tsx} : Make elements with interactive roles and handlers focusable.
📚 Learning: 2025-08-09T09:03:49.797Z
Learnt from: CR
PR: OpenCut-app/OpenCut#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-09T09:03:49.797Z
Learning: Applies to **/*.{jsx,tsx} : Make static elements with click handlers use a valid role attribute.
Applied to files:
apps/web/src/components/editor/media-panel/drag-overlay.tsx
📚 Learning: 2025-08-09T09:03:49.797Z
Learnt from: CR
PR: OpenCut-app/OpenCut#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-09T09:03:49.797Z
Learning: Applies to **/*.{jsx,tsx} : Don't use event handlers on non-interactive elements.
Applied to files:
apps/web/src/components/editor/media-panel/drag-overlay.tsx
📚 Learning: 2025-08-15T00:50:09.126Z
Learnt from: CR
PR: OpenCut-app/OpenCut#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-08-15T00:50:09.126Z
Learning: Applies to **/*.{tsx,jsx} : Accompany onClick with at least one of: onKeyUp, onKeyDown, or onKeyPress
Applied to files:
apps/web/src/components/editor/media-panel/drag-overlay.tsx
🧬 Code graph analysis (1)
apps/web/src/components/editor/media-panel/drag-overlay.tsx (1)
apps/web/src/lib/utils.ts (1)
cn(6-8)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Vade Review
🔇 Additional comments (4)
apps/web/src/components/editor/media-panel/drag-overlay.tsx (4)
1-1: Icon import looks good.No issues with lucide-react icon usage.
3-3: Good use of cn for conditional classes.This keeps class composition clean and deduped.
29-29: Correct isClickable guard.This boolean captures the interactive state succinctly and enables the cursor fix.
38-38: No action.Whitespace-only change.
| "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} |
There was a problem hiding this comment.
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.
| 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.
|
Since it already was a div, I kept it as a div. Should I convert it to a |
Description
Fixes incorrect cursor behavior in MediaDragOverlay. Previously, the overlay always showed the default cursor on hover, even when it was clickable. Now it only shows cursor-pointer when onClick is provided and isProcessing is false
Fixes # none
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
isProcessing=true: cursor stays default.isProcessing=false && onClick: cursor shows pointer.isProcessing=false && !onClick: cursor stays default.No new tests were added since this change only affects cursor styling (Tailwind utility class).
The behavior is deterministic and does not impact runtime logic
Test Configuration:
Screenshots
Checklist:
Summary by CodeRabbit