From 0d366f75775314eb9d7f4589d828d9fa27c7867c Mon Sep 17 00:00:00 2001 From: Anton Tranelis Date: Mon, 25 Mar 2024 01:57:17 +0100 Subject: [PATCH] fix search issues --- .../Map/Subcomponents/Controls/SearchControl.tsx | 5 ++--- src/Components/Profile/OverlayItemProfile.tsx | 16 ++++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Components/Map/Subcomponents/Controls/SearchControl.tsx b/src/Components/Map/Subcomponents/Controls/SearchControl.tsx index 67b23d5f..abbe2a67 100644 --- a/src/Components/Map/Subcomponents/Controls/SearchControl.tsx +++ b/src/Components/Map/Subcomponents/Controls/SearchControl.tsx @@ -116,10 +116,9 @@ export const SearchControl = () => { {itemsResults.slice(0, 5).map(item => (
{ const marker = Object.entries(leafletRefs).find(r => r[1].item == item)?.[1].marker; - if(marker){ + resetFilterTags(); + if(marker && filterTags.length == 0){ navigate(`/${item.layer.name}/${item.id}`) - - } else { navigate("item/"+item.id) diff --git a/src/Components/Profile/OverlayItemProfile.tsx b/src/Components/Profile/OverlayItemProfile.tsx index f2424cea..2f70f0b0 100644 --- a/src/Components/Profile/OverlayItemProfile.tsx +++ b/src/Components/Profile/OverlayItemProfile.tsx @@ -36,7 +36,6 @@ export function OverlayItemProfile() { const updateItem = useUpdateItem(); const [item, setItem] = useState({} as Item) const map = useMap(); - const windowDimension = useWindowDimensions(); const layers = useLayers(); const selectPosition = useSelectPosition(); const removeItem = useRemoveItem(); @@ -77,8 +76,12 @@ export function OverlayItemProfile() { const itemId = location.pathname.split("/")[2]; const item = items.find(i => i.id === itemId); item && setItem(item); - resetFilterTags(); - if (item && filterTags.length == 0) { + + + }, [items,location]) + + useEffect(() => { + if (item) { if(item.position) { const marker = Object.entries(leafletRefs).find(r => r[1].item == item)?.[1].marker; marker && clusterRef?.zoomToShowLayer(marker, () => { @@ -97,8 +100,9 @@ export function OverlayItemProfile() { ); } } + }, [item]) + - }, [items, activeTab, leafletRefs]) useEffect(() => { @@ -116,7 +120,7 @@ export function OverlayItemProfile() { const item = items.find(i => i.id == r.related_items_id) item && setRelations(current => [...current, item]) }) - }, [item, items]) + }, [item]) useEffect(() => { item && item.user_created && hasUserPermission("items", "update", item) && setUpdatePermission(true); @@ -234,7 +238,7 @@ export function OverlayItemProfile() { return ( <> {item && - + <> navigate("/edit-item/" + item.id)} setPositionCallback={()=>{map.closePopup();setSelectPosition(item); navigate("/")}} big />