fix: collapse map layers on zone selection

This commit is contained in:
Nico 2026-06-04 10:17:30 -07:00
parent 6a5d90df09
commit 1b7aaa1989
2 changed files with 11 additions and 1 deletions

View File

@ -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]

View File

@ -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);