Use correct ItemFormPopup for new items

This commit is contained in:
Maximilian Harz 2025-04-14 19:10:28 +02:00
parent 1786de7270
commit 618bdf290e

View File

@ -5,7 +5,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { useEffect, useRef, useState } from 'react' import { useContext, useEffect, useRef, useState } from 'react'
import { Popup as LeafletPopup, useMap } from 'react-leaflet' import { Popup as LeafletPopup, useMap } from 'react-leaflet'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
@ -17,6 +17,7 @@ import { useResetFilterTags } from '#components/Map/hooks/useFilter'
import { useAddItem, useItems, useUpdateItem } from '#components/Map/hooks/useItems' import { useAddItem, useItems, useUpdateItem } from '#components/Map/hooks/useItems'
import { usePopupForm } from '#components/Map/hooks/usePopupForm' import { usePopupForm } from '#components/Map/hooks/usePopupForm'
import { useAddTag, useTags } from '#components/Map/hooks/useTags' import { useAddTag, useTags } from '#components/Map/hooks/useTags'
import LayerContext from '#components/Map/LayerContext'
import { hashTagRegex } from '#utils/HashTagRegex' import { hashTagRegex } from '#utils/HashTagRegex'
import { randomColor } from '#utils/RandomColor' import { randomColor } from '#utils/RandomColor'
@ -27,6 +28,9 @@ interface Props {
} }
export function ItemFormPopup(props: Props) { export function ItemFormPopup(props: Props) {
const layerContext = useContext(LayerContext)
const { menuText, name: activeLayerName } = layerContext
const { popupForm, setPopupForm } = usePopupForm() const { popupForm, setPopupForm } = usePopupForm()
const [spinner, setSpinner] = useState(false) const [spinner, setSpinner] = useState(false)
@ -150,7 +154,8 @@ export function ItemFormPopup(props: Props) {
}, [popupForm?.position]) }, [popupForm?.position])
return ( return (
popupForm && ( popupForm &&
popupForm.layer.name === activeLayerName && (
<LeafletPopup <LeafletPopup
minWidth={275} minWidth={275}
maxWidth={275} maxWidth={275}
@ -174,7 +179,7 @@ export function ItemFormPopup(props: Props) {
<div className='tw-h-3'></div> <div className='tw-h-3'></div>
) : ( ) : (
<div className='tw-flex tw-justify-center'> <div className='tw-flex tw-justify-center'>
<b className='tw-text-xl tw-text-center tw-font-bold'>{popupForm.layer.menuText}</b> <b className='tw-text-xl tw-text-center tw-font-bold'>{menuText}</b>
</div> </div>
)} )}