Skip to content

Commit

Permalink
[Synthetics] Make error popover disappear onMouseLeave of metric it…
Browse files Browse the repository at this point in the history
…em card (#155800)
  • Loading branch information
justinkambic authored Apr 26, 2023
1 parent a07bdc5 commit e01e123
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { DARK_THEME } from '@elastic/charts';
import { useTheme } from '@kbn/observability-plugin/public';
import { useDispatch, useSelector } from 'react-redux';
import moment from 'moment';
import { toggleErrorPopoverOpen } from '../../../../state';
import { selectErrorPopoverState, toggleErrorPopoverOpen } from '../../../../state';
import { useLocationName, useStatusByLocationOverview } from '../../../../hooks';
import { formatDuration } from '../../../../utils/formatting';
import { MonitorOverviewItem } from '../../../../../../../common/runtime_types';
Expand Down Expand Up @@ -63,6 +63,7 @@ export const MetricItem = ({
}) => {
const [isMouseOver, setIsMouseOver] = useState(false);
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
const isErrorPopoverOpen = useSelector(selectErrorPopoverState);
const locationName =
useLocationName({ locationId: monitor.location?.id })?.label || monitor.location?.id;
const { status, timestamp, ping, configIdByLocation } = useStatusByLocationOverview(
Expand All @@ -86,6 +87,9 @@ export const MetricItem = ({
}
}}
onMouseLeave={() => {
if (isErrorPopoverOpen) {
dispatch(toggleErrorPopoverOpen(null));
}
if (isMouseOver) {
setIsMouseOver(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ export const MetricItemIcon = ({
onMouseLeave={() => {
if (isPopoverOpen) {
return;
}
if (timer.current) {
} else if (timer.current) {
clearTimeout(timer.current);
}
}}
Expand Down

0 comments on commit e01e123

Please sign in to comment.