Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion packages/hotspot/src/hotspot/circle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,28 @@ class CircleComponent extends React.Component {
this.state = {
hovered: false,
};
this.groupRef = React.createRef();
}

componentDidMount() {
if (this.props.focused) {
this.moveGroupToTop();
}
}

componentDidUpdate(prevProps) {
// `focused` (keyboard focus) can turn on the hovered style without going through handleMouseEnter
if (!prevProps.focused && this.props.focused) {
this.moveGroupToTop();
}
}

moveGroupToTop = () => {
if (this.groupRef.current) {
this.groupRef.current.moveToTop();
}
};

handleClick = (e) => {
const { onClick, id, selected, disabled } = this.props;

Expand All @@ -28,6 +48,7 @@ class CircleComponent extends React.Component {
document.body.style.cursor = 'pointer';
}
this.setState({ hovered: true });
this.moveGroupToTop();
};

handleMouseLeave = () => {
Expand Down Expand Up @@ -92,7 +113,13 @@ class CircleComponent extends React.Component {
const useHoveredStyle = (hovered || focused) && hoverOutlineColor;

return (
<Group scaleX={scale} scaleY={scale} onMouseLeave={this.handleMouseLeave} onMouseEnter={this.handleMouseEnter}>
<Group
ref={this.groupRef}
scaleX={scale}
scaleY={scale}
onMouseLeave={this.handleMouseLeave}
onMouseEnter={this.handleMouseEnter}
>
<Circle
radius={radius}
fill={selected && selectedHotspotColor ? selectedHotspotColor : hotspotColor}
Expand Down
29 changes: 28 additions & 1 deletion packages/hotspot/src/hotspot/polygon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,28 @@ class PolygonComponent extends React.Component {
this.state = {
hovered: false,
};
this.groupRef = React.createRef();
}

componentDidMount() {
if (this.props.focused) {
this.moveGroupToTop();
}
}

componentDidUpdate(prevProps) {
// `focused` (keyboard focus) can turn on the hovered style without going through handleMouseEnter
if (!prevProps.focused && this.props.focused) {
this.moveGroupToTop();
}
}

moveGroupToTop = () => {
if (this.groupRef.current) {
this.groupRef.current.moveToTop();
}
};

getPolygonCenter = (points) => {
const x = points.map(({ x }) => x);
const y = points.map(({ y }) => y);
Expand Down Expand Up @@ -47,6 +67,7 @@ class PolygonComponent extends React.Component {
document.body.style.cursor = 'pointer';
}
this.setState({ hovered: true });
this.moveGroupToTop();
};

handleMouseLeave = () => {
Expand Down Expand Up @@ -137,7 +158,13 @@ class PolygonComponent extends React.Component {
const rectHeight = maxY - minY;

return (
<Group scaleX={scale} scaleY={scale} onMouseEnter={this.handleMouseEnter} onMouseLeave={this.handleMouseLeave}>
<Group
ref={this.groupRef}
scaleX={scale}
scaleY={scale}
onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave}
>
<Line
points={pointsParsed}
closed={true}
Expand Down
29 changes: 28 additions & 1 deletion packages/hotspot/src/hotspot/rectangle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,28 @@ class RectComponent extends React.Component {
this.state = {
hovered: false,
};
this.groupRef = React.createRef();
}

componentDidMount() {
if (this.props.focused) {
this.moveGroupToTop();
}
}

componentDidUpdate(prevProps) {
// `focused` (keyboard focus) can turn on the hovered style without going through handleMouseEnter
if (!prevProps.focused && this.props.focused) {
this.moveGroupToTop();
}
}

moveGroupToTop = () => {
if (this.groupRef.current) {
this.groupRef.current.moveToTop();
}
};

handleClick = (e) => {
const { onClick, id, selected, disabled } = this.props;

Expand All @@ -28,6 +48,7 @@ class RectComponent extends React.Component {
document.body.style.cursor = 'pointer';
}
this.setState({ hovered: true });
this.moveGroupToTop();
};

handleMouseLeave = () => {
Expand Down Expand Up @@ -107,7 +128,13 @@ class RectComponent extends React.Component {
const useHoveredStyle = (hovered || focused) && hoverOutlineColor;

return (
<Group scaleX={scale} scaleY={scale} onMouseLeave={this.handleMouseLeave} onMouseEnter={this.handleMouseEnter}>
<Group
ref={this.groupRef}
scaleX={scale}
scaleY={scale}
onMouseLeave={this.handleMouseLeave}
onMouseEnter={this.handleMouseEnter}
>
<Rect
x={x}
y={y}
Expand Down
Loading