Skip to content

Commit

Permalink
fix: hide minimap after user clicks on a button (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabyzif authored Jun 7, 2024
1 parent ae9a2b0 commit 21a399c
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/components/navigation/GlobalNavigation/HomeButton.tsx
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 (
<Popover
content={() => (
content={
<MiniMap
overviewHref={props.overviewHref}
onUnauthorizedClick={props.onUnauthorizedClick}
links={props.links}
onLinkClick={props.onLinkClick}
onLinkClick={handleLinkClick}
unauthorizedLinks={props.unauthorizedLinks}
activeLink={props.activeLink}
/>
)}
}
placement="rightBottom"
open={isPopoverOpen}
onOpenChange={handlePopoverOpenChange}
arrow={false}>
<MpHomeButton onClick={props.onPopoverClick} />
</Popover>
Expand Down

0 comments on commit 21a399c

Please sign in to comment.