Skip to content

Commit

Permalink
close vesselGroupList on click
Browse files Browse the repository at this point in the history
  • Loading branch information
j8seangel committed Aug 30, 2024
1 parent fee4cf7 commit 7bf1e4c
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions apps/fishing-map/features/vessel-groups/VesselGroupListTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ function VesselGroupListTooltip(props: VesselGroupListTooltipProps) {
}
}, [vesselGroupOptions?.length, vesselGroupsOpen])

const handleVesselGroupClick = useCallback(
(vesselGroupId: string) => {
if (onAddToVesselGroup) {
onAddToVesselGroup(vesselGroupId)
setVesselGroupsOpen(false)
}
},
[onAddToVesselGroup]
)

return (
<Popover
open={vesselGroupsOpen}
Expand All @@ -41,7 +51,7 @@ function VesselGroupListTooltip(props: VesselGroupListTooltipProps) {
{hasUserGroupsPermissions && (
<li
className={cx(styles.groupOption, styles.groupOptionNew)}
onClick={() => onAddToVesselGroup?.(NEW_VESSEL_GROUP_ID)}
onClick={() => handleVesselGroupClick(NEW_VESSEL_GROUP_ID)}
key="new-group"
>
{t('vesselGroup.createNewGroup', 'Create new group')}
Expand All @@ -51,11 +61,7 @@ function VesselGroupListTooltip(props: VesselGroupListTooltipProps) {
<li
className={styles.groupOption}
key={group.id}
onClick={
!group.loading && onAddToVesselGroup
? () => onAddToVesselGroup(group.id)
: undefined
}
onClick={!group.loading ? () => handleVesselGroupClick(group.id) : undefined}
>
{group.label}
{group.loading && <Spinner className={styles.groupLoading} size="tiny" />}
Expand Down

0 comments on commit 7bf1e4c

Please sign in to comment.