From 5706db03a46b34493a1df4f621ef78f03b81362c Mon Sep 17 00:00:00 2001 From: Carlos Crespo Date: Thu, 12 Dec 2024 14:11:02 +0100 Subject: [PATCH] keep fidelity with refactored class component --- .../components/logging/log_minimap/log_minimap.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/observability_solution/infra/public/components/logging/log_minimap/log_minimap.tsx b/x-pack/plugins/observability_solution/infra/public/components/logging/log_minimap/log_minimap.tsx index 72aa0c4f558c7..821b9bb8f9eb8 100644 --- a/x-pack/plugins/observability_solution/infra/public/components/logging/log_minimap/log_minimap.tsx +++ b/x-pack/plugins/observability_solution/infra/public/components/logging/log_minimap/log_minimap.tsx @@ -15,7 +15,7 @@ import moment from 'moment'; import * as React from 'react'; import { css } from '@emotion/react'; import { useEuiTheme } from '@elastic/eui'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import { DensityChart } from './density_chart'; import { HighlightedInterval } from './highlighted_interval'; import { SearchMarkers } from './search_markers'; @@ -58,11 +58,16 @@ export const LogMinimap = ({ summaryBuckets, summaryHighlightBuckets, width, - target, + target: initialTarget, }: LogMinimapProps) => { const [timeCursorY, setTimeCursorY] = useState(0); + const [target, setTarget] = useState(initialTarget); const theme = useEuiTheme(); + useEffect(() => { + setTarget(initialTarget); + }, [initialTarget]); + const handleClick: React.MouseEventHandler = (event) => { const minimapTop = event.currentTarget.getBoundingClientRect().top; const clickedYPosition = event.clientY - minimapTop;