only update browser url if no profile is open

This commit is contained in:
Anton Tranelis 2025-11-14 09:53:54 +01:00
parent 9092241461
commit ccb667c7cc

View File

@ -160,20 +160,28 @@ export function UtopiaMapInner({
useMapEvents({ useMapEvents({
popupopen: (e) => { popupopen: (e) => {
const item = Object.entries(leafletRefs).find((r) => r[1].popup === e.popup)?.[1].item const item = Object.entries(leafletRefs).find((r) => r[1].popup === e.popup)?.[1].item
if (window.location.pathname.split('/')[1] !== item?.id) {
if (!location.pathname.includes('/item/') && item?.id) { // Only update URL if no profile is open
if (!location.pathname.includes('/item/')) {
if (window.location.pathname.split('/')[1] !== item?.id && item?.id) {
setItemInUrl(item.id) setItemInUrl(item.id)
} }
if (item?.name) { if (item?.name) {
updateMetaTags(item.name, item.text) updateMetaTags(item.name, item.text)
} }
} }
// If profile is open, don't change URL but still update meta tags
else if (item?.name) {
updateMetaTags(item.name, item.text)
}
}, },
popupclose: () => { popupclose: () => {
// Remove UUID from URL when popup closes // Only remove UUID from URL if no profile is open
if (containsUUID(window.location.pathname)) { if (!location.pathname.includes('/item/')) {
removeItemFromUrl() if (containsUUID(window.location.pathname)) {
resetMetaTagsUtil() removeItemFromUrl()
resetMetaTagsUtil()
}
} }
}, },
}) })