From 1f52d43ca4ab62b66920d2079d982afbbbe4540c Mon Sep 17 00:00:00 2001 From: Nico Date: Thu, 4 Jun 2026 04:14:42 -0700 Subject: [PATCH] fix: stabilize map manager size props --- frontend/src/pages/LocationMapManager.jsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/frontend/src/pages/LocationMapManager.jsx b/frontend/src/pages/LocationMapManager.jsx index ffd67ce..7fbafb9 100644 --- a/frontend/src/pages/LocationMapManager.jsx +++ b/frontend/src/pages/LocationMapManager.jsx @@ -78,7 +78,10 @@ export default function LocationMapManager() { const location = mapState?.location || stores.find((store) => String(store.id) === String(locationId)); const canManage = Boolean(mapState?.can_manage ?? ["owner", "admin"].includes(activeHousehold?.role)); - const activeMap = mapForMode(mapState, mode, previewDraft); + const activeMap = useMemo( + () => mapForMode(mapState, mode, previewDraft), + [mapState, mode, previewDraft] + ); const mapItems = mapState?.items || EMPTY_MAP_ITEMS; const selectedObject = useMemo( () => objects.find((object) => getObjectKey(object) === selectedObjectKey) || null, @@ -119,10 +122,13 @@ export default function LocationMapManager() { ); const shouldGuardLeave = canManage && hasUnsavedChanges; - const mapSize = { - width: mapDraft.width || activeMap?.width || DEFAULT_MAP_SIZE.width, - height: mapDraft.height || activeMap?.height || DEFAULT_MAP_SIZE.height, - }; + const mapSize = useMemo( + () => ({ + width: mapDraft.width || activeMap?.width || DEFAULT_MAP_SIZE.width, + height: mapDraft.height || activeMap?.height || DEFAULT_MAP_SIZE.height, + }), + [activeMap?.height, activeMap?.width, mapDraft.height, mapDraft.width] + ); useBeforeUnload( useCallback((event) => {