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 72aa0c4f558c..821b9bb8f9eb 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;