mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[ML] fix chartTooltip$ observable usage (#55694)
This commit is contained in:
parent
841afe32fc
commit
a895977aca
1 changed files with 3 additions and 4 deletions
|
@ -9,12 +9,11 @@ import React, { useRef, FC } from 'react';
|
|||
import { TooltipValueFormatter } from '@elastic/charts';
|
||||
import useObservable from 'react-use/lib/useObservable';
|
||||
|
||||
import { chartTooltip$, ChartTooltipValue } from './chart_tooltip_service';
|
||||
import { chartTooltip$, ChartTooltipState, ChartTooltipValue } from './chart_tooltip_service';
|
||||
|
||||
type RefValue = HTMLElement | null;
|
||||
|
||||
function useRefWithCallback() {
|
||||
const chartTooltipState = useObservable(chartTooltip$);
|
||||
function useRefWithCallback(chartTooltipState?: ChartTooltipState) {
|
||||
const ref = useRef<RefValue>(null);
|
||||
|
||||
return (node: RefValue) => {
|
||||
|
@ -66,7 +65,7 @@ const renderHeader = (headerData?: ChartTooltipValue, formatter?: TooltipValueFo
|
|||
|
||||
export const ChartTooltip: FC = () => {
|
||||
const chartTooltipState = useObservable(chartTooltip$);
|
||||
const chartTooltipElement = useRefWithCallback();
|
||||
const chartTooltipElement = useRefWithCallback(chartTooltipState);
|
||||
|
||||
if (chartTooltipState === undefined || !chartTooltipState.isTooltipVisible) {
|
||||
return <div className="mlChartTooltip mlChartTooltip--hidden" ref={chartTooltipElement} />;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue