From 578a7fd75d0bb0aaaf5a1ad5d620e161259013d8 Mon Sep 17 00:00:00 2001 From: Chris Berry Date: Tue, 12 Feb 2019 07:49:52 -0800 Subject: [PATCH] fix(core): only use for popovers in within SVGs (#6530) --- .../config/graph/PipelineGraphNode.tsx | 7 +++- .../stages/group/GroupExecutionPopover.tsx | 11 +++++- .../src/presentation/HoverablePopover.tsx | 38 +++++++++++-------- 3 files changed, 38 insertions(+), 18 deletions(-) diff --git a/app/scripts/modules/core/src/pipeline/config/graph/PipelineGraphNode.tsx b/app/scripts/modules/core/src/pipeline/config/graph/PipelineGraphNode.tsx index f54a1af85f6..ea62223fc9a 100644 --- a/app/scripts/modules/core/src/pipeline/config/graph/PipelineGraphNode.tsx +++ b/app/scripts/modules/core/src/pipeline/config/graph/PipelineGraphNode.tsx @@ -152,7 +152,12 @@ export class PipelineGraphNode extends React.Component if (node.stage && node.stage.type === 'group') { NodeContents = ( - + {NodeContents} ); diff --git a/app/scripts/modules/core/src/pipeline/config/stages/group/GroupExecutionPopover.tsx b/app/scripts/modules/core/src/pipeline/config/stages/group/GroupExecutionPopover.tsx index e68382b3941..7e47d11efa7 100644 --- a/app/scripts/modules/core/src/pipeline/config/stages/group/GroupExecutionPopover.tsx +++ b/app/scripts/modules/core/src/pipeline/config/stages/group/GroupExecutionPopover.tsx @@ -9,6 +9,7 @@ export interface IGroupExecutionPopoverProps { stage: IExecutionStageSummary; width: number; subStageClicked?: (groupStage: IExecutionStageSummary, stage: IExecutionStageSummary) => void; + svgMode?: boolean; } export interface IGroupedStageListItemProps { @@ -55,7 +56,7 @@ export class GroupExecutionPopover extends React.Component @@ -69,7 +70,13 @@ export class GroupExecutionPopover extends React.Component + {this.props.children} ); diff --git a/app/scripts/modules/core/src/presentation/HoverablePopover.tsx b/app/scripts/modules/core/src/presentation/HoverablePopover.tsx index 22d0f0c7ee4..143cbaf4efc 100644 --- a/app/scripts/modules/core/src/presentation/HoverablePopover.tsx +++ b/app/scripts/modules/core/src/presentation/HoverablePopover.tsx @@ -41,6 +41,7 @@ export interface IHoverablePopoverProps extends React.HTMLProps { onShow?: () => void; onHide?: () => void; + svgMode?: boolean; } export interface IHoverablePopoverState { @@ -58,11 +59,10 @@ export class HoverablePopover extends React.Component>(); private hidePopoverEvents$ = new Subject(); private destroy$ = new Subject(); + private targetRef = React.createRef(); constructor(props: IHoverablePopoverProps) { super(props); @@ -103,14 +103,10 @@ export class HoverablePopover extends React.Component { - this.target = ref; - }; - private rendererRefCallback = (ref: React.Component): void => { if (ref) { const { clientWidth, clientHeight } = ReactDOM.findDOMNode(ref) as Element; - const bounds = this.target.getBoundingClientRect(); + const bounds = this.targetRef.current.getBoundingClientRect(); const bottomSpace = window.innerHeight - bounds.bottom; const rightSpace = window.innerWidth - bounds.right; @@ -133,9 +129,26 @@ export class HoverablePopover extends React.Component { + const { svgMode } = this.props; + if (svgMode) { + return ( + + {children} + + ); + } + return ( +
+ {children} +
+ ); + }; + public render() { const { Component, template, placement, container, hOffsetPercent, id, title, className } = this.props; const { popoverIsOpen, animation, placementOverride } = this.state; + const { Wrapper } = this; const popoverContent: JSX.Element = Component ? ( this.hidePopoverEvents$.next()} /> @@ -144,18 +157,13 @@ export class HoverablePopover extends React.Component + {this.props.children} -
+ ); } }