mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2026-03-01 12:44:17 +00:00
fix back and forth with browser nav
This commit is contained in:
parent
ccb667c7cc
commit
8cc87a24d8
@ -157,10 +157,19 @@ export function UtopiaMapInner({
|
||||
return null
|
||||
}
|
||||
|
||||
// Track if we're currently switching popups to prevent URL cleanup
|
||||
const popupCloseTimeoutRef = useRef<NodeJS.Timeout | null>(null)
|
||||
|
||||
useMapEvents({
|
||||
popupopen: (e) => {
|
||||
const item = Object.entries(leafletRefs).find((r) => r[1].popup === e.popup)?.[1].item
|
||||
|
||||
// Cancel any pending popup close URL cleanup - we're opening a new popup
|
||||
if (popupCloseTimeoutRef.current) {
|
||||
clearTimeout(popupCloseTimeoutRef.current)
|
||||
popupCloseTimeoutRef.current = null
|
||||
}
|
||||
|
||||
// Only update URL if no profile is open
|
||||
if (!location.pathname.includes('/item/')) {
|
||||
if (window.location.pathname.split('/')[1] !== item?.id && item?.id) {
|
||||
@ -178,10 +187,15 @@ export function UtopiaMapInner({
|
||||
popupclose: () => {
|
||||
// Only remove UUID from URL if no profile is open
|
||||
if (!location.pathname.includes('/item/')) {
|
||||
if (containsUUID(window.location.pathname)) {
|
||||
removeItemFromUrl()
|
||||
resetMetaTagsUtil()
|
||||
}
|
||||
// Wait briefly to see if another popup is being opened
|
||||
// If so, the popupopen handler will cancel this timeout
|
||||
popupCloseTimeoutRef.current = setTimeout(() => {
|
||||
if (containsUUID(window.location.pathname)) {
|
||||
removeItemFromUrl()
|
||||
resetMetaTagsUtil()
|
||||
}
|
||||
popupCloseTimeoutRef.current = null
|
||||
}, 50)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user