close new item form when switching layers

This commit is contained in:
Anton Tranelis 2024-07-29 20:39:25 +02:00
parent 53598fc066
commit 1d53ba3f9c

View File

@ -22,12 +22,6 @@ import { TagsControl } from '../Map/Subcomponents/Controls/TagsControl';
import { useFilterTags } from '../Map/hooks/useFilter';
type breadcrumb = {
name: string,
path: string
}
export const OverlayItemsIndexPage = ({ url, layerName, parameterField, plusButton = true }: { layerName: string, url: string, parameterField: string, plusButton?: boolean }) => {
@ -45,6 +39,11 @@ export const OverlayItemsIndexPage = ({ url, layerName, parameterField, plusButt
scroll();
}, [addItemPopupType])
useEffect(() => {
setAddItemPopupType("");
}, [layerName])
const tags = useTags();
const addTag = useAddTag();
const { user } = useAuth();
@ -134,10 +133,9 @@ export const OverlayItemsIndexPage = ({ url, layerName, parameterField, plusButt
</div>
))
}
</div>
{addItemPopupType == "place" && (
<form ref={tabRef} autoComplete='off' onSubmit={e => submitNewItem(e)}>
<div className='tw-cursor-pointer tw-card tw-border-[1px] tw-border-base-300 tw-card-body tw-shadow-xl tw-bg-base-100 tw-text-base-content tw-p-6 tw-mb-10'>
<div className='tw-cursor-pointer tw-break-inside-avoid tw-card tw-border-[1px] tw-border-base-300 tw-card-body tw-shadow-xl tw-bg-base-100 tw-text-base-content tw-p-6 tw-mb-10'>
<label className="tw-btn tw-btn-sm tw-rounded-2xl tw-btn-circle tw-btn-ghost hover:tw-bg-transparent tw-absolute tw-right-0 tw-top-0 tw-text-gray-600" onClick={() => setAddItemPopupType("")}>
<p className='tw-text-center'></p>
</label>
@ -153,9 +151,12 @@ export const OverlayItemsIndexPage = ({ url, layerName, parameterField, plusButt
</form>
)}
</div>
</div>
</div>
</MapOverlayPage>
{plusButton && <PlusButton layer={layer} triggerAction={() => { setAddItemPopupType("place"); scroll(); }} color={'#777'} collection='items' />}
</>
)}
)
}