Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hide minimap after user clicks on a button #264

Merged
merged 3 commits into from
Jun 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit null check?

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
Loading