-
{props.layer.menuText}
+ popupForm && (
+
{
+ setTimeout(function () {
+ resetPopup()
+ }, 100)
+ },
+ }}
+ position={popupForm.position}
+ >
+
-
+
+
+ )
)
}
diff --git a/src/Components/Map/Subcomponents/ItemViewPopup.tsx b/src/Components/Map/Subcomponents/ItemViewPopup.tsx
index a621c1bf..4a6f5925 100644
--- a/src/Components/Map/Subcomponents/ItemViewPopup.tsx
+++ b/src/Components/Map/Subcomponents/ItemViewPopup.tsx
@@ -44,12 +44,16 @@ export const ItemViewPopup = forwardRef((props: ItemViewPopupProps, ref: any) =>
event.stopPropagation()
map.closePopup()
+ if (!props.item.layer) {
+ throw new Error('Layer is not defined')
+ }
+
setPopupForm({
position: new LatLng(
props.item.position?.coordinates[1]!,
props.item.position?.coordinates[0]!,
),
- layer: props.item.layer!,
+ layer: props.item.layer,
item: props.item,
})
}
diff --git a/src/Components/Map/UtopiaMapInner.tsx b/src/Components/Map/UtopiaMapInner.tsx
index 97a0302a..64860a1a 100644
--- a/src/Components/Map/UtopiaMapInner.tsx
+++ b/src/Components/Map/UtopiaMapInner.tsx
@@ -63,16 +63,14 @@ export function UtopiaMapInner({
const clusterRef = useClusterRef()
const setMapClicked = useSetMapClicked()
const { setPopupForm } = usePopupForm()
-
- useTheme(defaultTheme)
-
const layers = useLayers()
const addVisibleLayer = useAddVisibleLayer()
const leafletRefs = useLeafletRefs()
-
const location = useLocation()
const map = useMap()
+ useTheme(defaultTheme)
+
useEffect(() => {
layers.forEach((layer) => addVisibleLayer(layer))
// eslint-disable-next-line react-hooks/exhaustive-deps
diff --git a/src/Components/Map/hooks/usePopupForm.tsx b/src/Components/Map/hooks/usePopupForm.tsx
index 7e2f5f20..236b931f 100644
--- a/src/Components/Map/hooks/usePopupForm.tsx
+++ b/src/Components/Map/hooks/usePopupForm.tsx
@@ -1,19 +1,19 @@
import { createContext, useContext, useState } from 'react'
-import type { ItemFormPopupProps } from '#types/ItemFormPopupProps'
+import type { PopupFormState } from '#types/PopupFormState'
type UsePopupFormManagerResult = ReturnType
const PoupFormContext = createContext({
- popupForm: {} as ItemFormPopupProps | null,
+ popupForm: {} as PopupFormState | null,
setPopupForm: () => {},
})
function usePopupFormManager(): {
- popupForm: ItemFormPopupProps | null
- setPopupForm: React.Dispatch>
+ popupForm: PopupFormState | null
+ setPopupForm: React.Dispatch>
} {
- const [popupForm, setPopupForm] = useState(null)
+ const [popupForm, setPopupForm] = useState(null)
return { popupForm, setPopupForm }
}
diff --git a/src/Components/Map/hooks/useSelectPosition.tsx b/src/Components/Map/hooks/useSelectPosition.tsx
index e53e0193..ace7aaee 100644
--- a/src/Components/Map/hooks/useSelectPosition.tsx
+++ b/src/Components/Map/hooks/useSelectPosition.tsx
@@ -15,14 +15,14 @@ import { useUpdateItem } from './useItems'
import { useHasUserPermission } from './usePermissions'
import type { Item } from '#types/Item'
-import type { ItemFormPopupProps } from '#types/ItemFormPopupProps'
+import type { PopupFormState } from '#types/PopupFormState'
import type { LayerProps } from '#types/LayerProps'
import type { Point } from 'geojson'
import type { LatLng } from 'leaflet'
interface PolygonClickedProps {
position: LatLng
- setItemFormPopup: React.Dispatch>
+ setItemFormPopup: React.Dispatch>
}
type UseSelectPositionManagerResult = ReturnType
diff --git a/src/types/ItemFormPopupProps.d.ts b/src/types/PopupFormState.ts
similarity index 72%
rename from src/types/ItemFormPopupProps.d.ts
rename to src/types/PopupFormState.ts
index 8d715be2..1cf0890d 100644
--- a/src/types/ItemFormPopupProps.d.ts
+++ b/src/types/PopupFormState.ts
@@ -2,9 +2,8 @@ import type { Item } from './Item'
import type { LayerProps } from './LayerProps'
import type { LatLng } from 'leaflet'
-export interface ItemFormPopupProps {
+export interface PopupFormState {
position: LatLng
layer: LayerProps
item?: Item
- children?: React.ReactNode
}