mirror of
https://github.com/grafana/grafana.git
synced 2026-07-30 08:18:10 -05:00
Tooltip: Set tooltip of active panel to front of zIndex (#70747)
* Set active graph tooltip to front * added zIndexOffset to Props * Use className in TooltipPlugin Co-authored-by: sjd210 <solomon.dubock@grafana.com> * Change to UseStyles2 pattern --------- Co-authored-by: Victor Marin <victor.marin@grafana.com> Co-authored-by: sjd210 <solomon.dubock@grafana.com>
This commit is contained in:
co-authored by
sjd210
Victor Marin
parent
116e971af3
commit
b1555c9595
@@ -1,3 +1,4 @@
|
||||
import { css } from '@emotion/css';
|
||||
import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
||||
import { useMountedState } from 'react-use';
|
||||
import uPlot from 'uplot';
|
||||
@@ -12,11 +13,12 @@ import {
|
||||
formattedValueToString,
|
||||
getDisplayProcessor,
|
||||
getFieldDisplayName,
|
||||
GrafanaTheme2,
|
||||
TimeZone,
|
||||
} from '@grafana/data';
|
||||
import { TooltipDisplayMode, SortOrder } from '@grafana/schema';
|
||||
|
||||
import { useTheme2 } from '../../../themes/ThemeContext';
|
||||
import { useStyles2, useTheme2 } from '../../../themes/ThemeContext';
|
||||
import { Portal } from '../../Portal/Portal';
|
||||
import { SeriesTable, SeriesTableRowProps, VizTooltipContainer } from '../../VizTooltip';
|
||||
import { UPlotConfigBuilder } from '../config/UPlotConfigBuilder';
|
||||
@@ -272,8 +274,10 @@ export const TooltipPlugin = ({
|
||||
tooltip = renderTooltip(otherProps.data, focusedSeriesIdx, focusedPointIdx);
|
||||
}
|
||||
|
||||
const style = useStyles2(getStyles);
|
||||
|
||||
return (
|
||||
<Portal>
|
||||
<Portal className={isActive ? style.tooltipWrapper : undefined}>
|
||||
{tooltip && coords && (
|
||||
<VizTooltipContainer position={{ x: coords.x, y: coords.y }} offset={{ x: TOOLTIP_OFFSET, y: TOOLTIP_OFFSET }}>
|
||||
{tooltip}
|
||||
@@ -321,3 +325,9 @@ export function positionTooltip(u: uPlot, bbox: DOMRect) {
|
||||
|
||||
return { x, y };
|
||||
}
|
||||
|
||||
const getStyles = (theme: GrafanaTheme2) => ({
|
||||
tooltipWrapper: css`
|
||||
z-index: ${theme.zIndex.portal + 1} !important;
|
||||
`,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user