From 21a399c3afb60bde0737d472db095fba22c41d63 Mon Sep 17 00:00:00 2001 From: Gaby Zifferman Date: Fri, 7 Jun 2024 12:24:04 +0200 Subject: [PATCH] fix: hide minimap after user clicks on a button (#264) --- .../GlobalNavigation/HomeButton.tsx | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/components/navigation/GlobalNavigation/HomeButton.tsx b/src/components/navigation/GlobalNavigation/HomeButton.tsx index f4f061833..31253d12f 100644 --- a/src/components/navigation/GlobalNavigation/HomeButton.tsx +++ b/src/components/navigation/GlobalNavigation/HomeButton.tsx @@ -1,7 +1,7 @@ -import React from 'react' +import React, { useState } from 'react' import { Center, Icon, Popover, Tooltip } from 'src/components' import MiniMap from 'src/components/navigation/MiniMap/MiniMap' -import { IMiniMapOptions } from 'src/components/navigation/GlobalNavigation/GlobalNavigationItems' +import { IMiniMapOptions, MiniMapLink } from 'src/components/navigation/GlobalNavigation/GlobalNavigationItems' interface MpHomeButtonProps { onClick: () => void @@ -29,19 +29,30 @@ function MpHomeButton(props: MpHomeButtonProps) { } function MinimapWithPopover(props: MinimapWithPopoverProps) { + const [isPopoverOpen, setIsPopoverOpen] = useState(false) + const handleLinkClick = (link: MiniMapLink) => { + setIsPopoverOpen(false) + props.onLinkClick(link) + } + const handlePopoverOpenChange = (newPopoverState: boolean) => { + setIsPopoverOpen(newPopoverState) + } + return ( ( + content={ - )} + } placement="rightBottom" + open={isPopoverOpen} + onOpenChange={handlePopoverOpenChange} arrow={false}>