diff --git a/frontend/src/components/maps/LocationMapBottomSheet.jsx b/frontend/src/components/maps/LocationMapBottomSheet.jsx index 8743896..4215665 100644 --- a/frontend/src/components/maps/LocationMapBottomSheet.jsx +++ b/frontend/src/components/maps/LocationMapBottomSheet.jsx @@ -1,4 +1,4 @@ -import { useMemo } from "react"; +import { useEffect, useMemo } from "react"; import { DEFAULT_MAP_FILTERS, getMapObjectDisplayLabel, @@ -82,6 +82,13 @@ export default function LocationMapBottomSheet({ const showEditorControls = mode === "edit" && canManage; const showSelectedObjectForm = Boolean(mode === "edit" && editorTool === "edit" && selectedObject); const showUnmappedPanel = filters.showUnmapped && !selectedObject; + + useEffect(() => { + if (selectedObject) { + setLayersOpen(false); + } + }, [selectedObject, setLayersOpen]); + const changedLayerCount = useMemo( () => MAP_DISPLAY_CONTROLS.filter(([key]) => filters[key] !== DEFAULT_MAP_FILTERS[key]).length, [filters] diff --git a/frontend/tests/location-map-manager.spec.ts b/frontend/tests/location-map-manager.spec.ts index df7af0f..9fad3bd 100644 --- a/frontend/tests/location-map-manager.spec.ts +++ b/frontend/tests/location-map-manager.spec.ts @@ -2163,11 +2163,14 @@ test("viewer hides unrelated unmapped items while a zone is selected", async ({ await page.goto("/stores/100/locations/10/map"); await page.getByRole("button", { name: "Layers" }).click(); await page.getByRole("button", { name: "Unmapped" }).click(); + await expect(page.locator(".location-map-display-panel")).toBeVisible(); await expect(page.getByText("Unmapped Items")).toBeVisible(); await expect(page.getByText("loose batteries")).toBeVisible(); await page.locator('[data-object-key="1531"]').locator("rect").first().click(); await expect(page.locator(".location-map-sheet-header strong")).toHaveText("Bakery"); + await expect(page.getByRole("button", { name: "Layers, 1 changed" })).toHaveAttribute("aria-expanded", "false"); + await expect(page.locator(".location-map-display-panel")).toHaveCount(0); await expect(page.getByText("french bread")).toBeVisible(); await expect(page.getByText("Unmapped Items")).toHaveCount(0); await expect(page.getByText("loose batteries")).toHaveCount(0);