Skip to content

Commit

Permalink
Bug 1776361: Show hover treatment for context menu's reference item
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-phillips-18 committed Nov 25, 2019
1 parent a90fe53 commit f3838c3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const ApplicationGroup: React.FC<ApplicationGroupProps> = ({
canDrop,
dropTarget,
onContextMenu,
contextMenuShown,
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) || contextMenuShown,
});

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 || contextMenuShown
? 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,
contextMenuShown,
}) => {
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 || contextMenuShown,
'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 || contextMenuShown
? 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,
contextMenuShown,
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 || contextMenuShown
? 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,
contextMenuShown,
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 || contextMenuShown
? 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;
contextMenuShown: 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}
contextMenuShown={!!reference}
/>
{reference ? (
<ContextMenu
reference={reference}
Expand Down

0 comments on commit f3838c3

Please sign in to comment.