Skip to content
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

Bug 1776361: Show hover treatment for context menu's reference item #3566

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const ApplicationGroup: React.FC<ApplicationGroupProps> = ({
canDrop,
dropTarget,
onContextMenu,
contextMenuOpen,
dragging,
}) => {
const [groupHover, groupHoverRef] = useHover();
Expand Down Expand Up @@ -120,7 +121,7 @@ const ApplicationGroup: React.FC<ApplicationGroupProps> = ({
const pathClasses = classNames('odc2-application-group', {
'is-highlight': canDrop,
'is-selected': selected,
'is-hover': hover || (canDrop && dropTarget),
'is-hover': hover || (canDrop && dropTarget) || contextMenuOpen,
});

return (
Expand All @@ -131,7 +132,9 @@ const ApplicationGroup: React.FC<ApplicationGroupProps> = ({
<path
ref={refs}
filter={createSvgIdUrl(
hover || dragging ? NODE_SHADOW_FILTER_ID_HOVER : NODE_SHADOW_FILTER_ID,
hover || dragging || contextMenuOpen
? NODE_SHADOW_FILTER_ID_HOVER
: NODE_SHADOW_FILTER_ID,
)}
className={pathClasses}
d={pathRef.current}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@ const BaseNode: React.FC<BaseNodeProps> = ({
onHideCreateConnector,
onShowCreateConnector,
onContextMenu,
contextMenuOpen,
}) => {
const [hover, hoverRef] = useHover();
useAnchor(EllipseAnchor);
const cx = element.getBounds().width / 2;
const cy = element.getBounds().height / 2;

const contentsClasses = classNames('odc2-base-node__contents', {
'is-hover': hover,
'is-hover': hover || contextMenuOpen,
'is-highlight': canDrop,
'is-dragging': dragging || edgeDragging,
'is-droppable': dropTarget && canDrop,
Expand Down Expand Up @@ -95,7 +96,7 @@ const BaseNode: React.FC<BaseNodeProps> = ({
cy={cy}
r={outerRadius}
filter={createSvgIdUrl(
hover || dragging || edgeDragging || dropTarget
hover || dragging || edgeDragging || dropTarget || contextMenuOpen
? NODE_SHADOW_FILTER_ID_HOVER
: NODE_SHADOW_FILTER_ID,
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const EventSource: React.FC<EventSourceProps> = ({
selected,
onSelect,
onContextMenu,
contextMenuOpen,
dragNodeRef,
dragging,
}) => {
Expand All @@ -50,7 +51,9 @@ const EventSource: React.FC<EventSourceProps> = ({
className="odc-event-source__bg"
ref={svgAnchorRef}
filter={createSvgIdUrl(
hover || dragging ? NODE_SHADOW_FILTER_ID_HOVER : NODE_SHADOW_FILTER_ID,
hover || dragging || contextMenuOpen
? NODE_SHADOW_FILTER_ID_HOVER
: NODE_SHADOW_FILTER_ID,
)}
points={`${width / 2}, ${(height - size) / 2} ${width - (width - size) / 2},${height /
2} ${width / 2},${height - (height - size) / 2} ${(width - size) / 2},${height / 2}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const KnativeService: React.FC<EventSourceProps> = ({
selected,
onSelect,
onContextMenu,
contextMenuOpen,
dragNodeRef,
dragging,
regrouping,
Expand Down Expand Up @@ -74,7 +75,9 @@ const KnativeService: React.FC<EventSourceProps> = ({
rx="5"
ry="5"
filter={createSvgIdUrl(
hover || innerHover || dragging ? NODE_SHADOW_FILTER_ID_HOVER : NODE_SHADOW_FILTER_ID,
hover || innerHover || dragging || contextMenuOpen
? NODE_SHADOW_FILTER_ID_HOVER
: NODE_SHADOW_FILTER_ID,
)}
/>
</Layer>
Expand Down
7 changes: 6 additions & 1 deletion frontend/packages/topology/src/behavior/withContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type Reference = React.ComponentProps<typeof ContextMenu>['reference'];

export type WithContextMenuProps = {
onContextMenu: (e: React.MouseEvent) => void;
contextMenuOpen: boolean;
};

export const withContextMenu = <E extends TopologyElement>(
Expand All @@ -34,7 +35,11 @@ export const withContextMenu = <E extends TopologyElement>(

return (
<>
<WrappedComponent {...props as any} onContextMenu={onContextMenu} />
<WrappedComponent
{...props as any}
onContextMenu={onContextMenu}
contextMenuOpen={!!reference}
/>
{reference ? (
<ContextMenu
reference={reference}
Expand Down