From 8d8b66d2660c4924441092a18d6cadeeb05b9675 Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Tue, 13 Sep 2022 12:46:01 +0300 Subject: [PATCH] Add boundary to tooltip (#2211) --- assets/js/dashboard/stats/graph/top-stats.js | 4 ++-- assets/js/dashboard/stats/graph/visitor-graph.js | 1 + assets/js/dashboard/util/tooltip.js | 8 +++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/assets/js/dashboard/stats/graph/top-stats.js b/assets/js/dashboard/stats/graph/top-stats.js index 25ad59581..b1ba6d0fe 100644 --- a/assets/js/dashboard/stats/graph/top-stats.js +++ b/assets/js/dashboard/stats/graph/top-stats.js @@ -45,7 +45,7 @@ export default class TopStats extends React.Component { return (
-
{this.topStatNumberLong(stat)} {statName}
+
{this.topStatNumberLong(stat)} {statName}
{this.canMetricBeGraphed(stat) &&
{this.titleFor(stat)}
}
) @@ -99,7 +99,7 @@ export default class TopStats extends React.Component { }) return ( - { this.maybeUpdateMetric(stat) }}> + { this.maybeUpdateMetric(stat) }} boundary={this.props.tooltipBoundary}>
{statDisplayName} diff --git a/assets/js/dashboard/stats/graph/visitor-graph.js b/assets/js/dashboard/stats/graph/visitor-graph.js index 88002f8fa..99ea8495b 100644 --- a/assets/js/dashboard/stats/graph/visitor-graph.js +++ b/assets/js/dashboard/stats/graph/visitor-graph.js @@ -48,6 +48,7 @@ export const METRIC_FORMATTER = { class LineGraph extends React.Component { constructor(props) { super(props); + this.boundary = React.createRef() this.regenerateChart = this.regenerateChart.bind(this); this.updateWindowDimensions = this.updateWindowDimensions.bind(this); this.state = { diff --git a/assets/js/dashboard/util/tooltip.js b/assets/js/dashboard/util/tooltip.js index 1600138ed..8cfc77a28 100644 --- a/assets/js/dashboard/util/tooltip.js +++ b/assets/js/dashboard/util/tooltip.js @@ -2,7 +2,7 @@ import React, { useState } from "react"; import { usePopper } from 'react-popper'; import classNames from 'classnames' -export function Tooltip({ children, info, className, onClick }) { +export function Tooltip({ children, info, className, onClick, boundary }) { const [visible, setVisible] = useState(false); const [referenceElement, setReferenceElement] = useState(null); const [popperElement, setPopperElement] = useState(null); @@ -17,6 +17,12 @@ export function Tooltip({ children, info, className, onClick }) { offset: [0, 4], }, }, + boundary && { + name: 'preventOverflow', + options: { + boundary: boundary, + }, + }, ], });