-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
component(ContextMenuViewport): move to ui-next with theme support #6008
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: master
Are you sure you want to change the base?
Changes from 5 commits
33b9a98
7e5ee69
178b0be
0173f26
1340448
16ef30a
7a4b4a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import { ContextMenu } from '@ohif/ui'; | ||
| import { ContextMenuViewport } from '@ohif/ui-next'; | ||
|
|
||
| export default { | ||
| 'ui.contextMenu': ContextMenu, | ||
| 'ui.contextMenu': ContextMenuViewport, | ||
| }; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,46 @@ | ||||||||||||||||||||||||||||
| import React from 'react'; | ||||||||||||||||||||||||||||
| import { Icons } from '../Icons'; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| interface ContextMenuViewportProps { | ||||||||||||||||||||||||||||
| items?: Array<{ | ||||||||||||||||||||||||||||
| label: string; | ||||||||||||||||||||||||||||
| action: (item: any, props: any) => void; | ||||||||||||||||||||||||||||
| iconRight?: string; | ||||||||||||||||||||||||||||
| [key: string]: unknown; | ||||||||||||||||||||||||||||
| }>; | ||||||||||||||||||||||||||||
| defaultPosition?: { x: number; y: number }; | ||||||||||||||||||||||||||||
| [key: string]: unknown; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const ContextMenuViewport = ({ items, ...props }: ContextMenuViewportProps) => { | ||||||||||||||||||||||||||||
| if (!items) { | ||||||||||||||||||||||||||||
| return null; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
dan-rukas marked this conversation as resolved.
Comment on lines
+15
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Avoid rendering an empty menu container when Line 16 only checks for falsy values; Suggested fix- if (!items) {
+ if (!items?.length) {
return null;
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||
| data-cy="context-menu" | ||||||||||||||||||||||||||||
| className="bg-popover text-popover-foreground animate-in fade-in-0 zoom-in-95 relative z-50 w-48 overflow-hidden rounded-md border border-input p-1 shadow-md" | ||||||||||||||||||||||||||||
| onContextMenu={e => e.preventDefault()} | ||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||
| {items.map((item, index) => ( | ||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||
| key={index} | ||||||||||||||||||||||||||||
| data-cy="context-menu-item" | ||||||||||||||||||||||||||||
| onClick={() => item.action(item, props)} | ||||||||||||||||||||||||||||
| className="hover:bg-accent hover:text-accent-foreground flex cursor-default select-none items-center justify-between rounded-sm px-2 py-1.5 text-base outline-none" | ||||||||||||||||||||||||||||
|
dan-rukas marked this conversation as resolved.
|
||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||
|
Comment on lines
+26
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Use keyboard-focusable controls for menu actions. Line 27 renders clickable rows as Suggested fix- <div
+ <button
+ type="button"
key={index}
data-cy="context-menu-item"
onClick={() => item.action(item, props)}
- className="hover:bg-accent hover:text-accent-foreground flex cursor-default select-none items-center justify-between rounded-sm px-2 py-1.5 text-base outline-none"
+ className="hover:bg-accent hover:text-accent-foreground flex w-full cursor-pointer select-none items-center justify-between rounded-sm px-2 py-1.5 text-base outline-none"
>
<span>{item.label}</span>
{item.iconRight && (
<Icons.ByName
name={item.iconRight}
className="inline"
/>
)}
- </div>
+ </button>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| <span>{item.label}</span> | ||||||||||||||||||||||||||||
| {item.iconRight && ( | ||||||||||||||||||||||||||||
| <Icons.ByName | ||||||||||||||||||||||||||||
| name={item.iconRight} | ||||||||||||||||||||||||||||
| className="inline" | ||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||
| ))} | ||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| export default ContextMenuViewport; | ||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { default as ContextMenuViewport } from './ContextMenuViewport'; |
Uh oh!
There was an error while loading. Please reload this page.