fix: stabilize map manager size props
This commit is contained in:
parent
b0cfaeba60
commit
1f52d43ca4
@ -78,7 +78,10 @@ export default function LocationMapManager() {
|
|||||||
|
|
||||||
const location = mapState?.location || stores.find((store) => String(store.id) === String(locationId));
|
const location = mapState?.location || stores.find((store) => String(store.id) === String(locationId));
|
||||||
const canManage = Boolean(mapState?.can_manage ?? ["owner", "admin"].includes(activeHousehold?.role));
|
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 mapItems = mapState?.items || EMPTY_MAP_ITEMS;
|
||||||
const selectedObject = useMemo(
|
const selectedObject = useMemo(
|
||||||
() => objects.find((object) => getObjectKey(object) === selectedObjectKey) || null,
|
() => objects.find((object) => getObjectKey(object) === selectedObjectKey) || null,
|
||||||
@ -119,10 +122,13 @@ export default function LocationMapManager() {
|
|||||||
);
|
);
|
||||||
const shouldGuardLeave = canManage && hasUnsavedChanges;
|
const shouldGuardLeave = canManage && hasUnsavedChanges;
|
||||||
|
|
||||||
const mapSize = {
|
const mapSize = useMemo(
|
||||||
width: mapDraft.width || activeMap?.width || DEFAULT_MAP_SIZE.width,
|
() => ({
|
||||||
height: mapDraft.height || activeMap?.height || DEFAULT_MAP_SIZE.height,
|
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(
|
useBeforeUnload(
|
||||||
useCallback((event) => {
|
useCallback((event) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user