fix: clear map selection with escape

This commit is contained in:
Nico 2026-06-04 10:27:36 -07:00
parent 1b7aaa1989
commit ada2193085
2 changed files with 13 additions and 0 deletions

View File

@ -146,6 +146,13 @@ export default function LocationMapCanvas({
};
const handleObjectKeyDown = (event, object) => {
if (event.key === "Escape" && (mode === "view" || canEditObjects)) {
event.stopPropagation();
event.preventDefault();
setSelectedObjectKey(null);
return;
}
if (["Enter", " ", "Spacebar"].includes(event.key)) {
event.stopPropagation();
event.preventDefault();

View File

@ -2541,6 +2541,12 @@ test("viewer map areas are keyboard selectable", async ({ page }) => {
await expect(bakeryArea).toHaveAttribute("aria-pressed", "false");
await expect(page.locator(".location-map-sheet-header strong")).toHaveText("Frozen Foods");
await expect(page.locator(".location-map-sheet-count")).toHaveText("0 shown");
await page.keyboard.press("Escape");
await expect(frozenArea).toBeFocused();
await expect(frozenArea).toHaveAttribute("aria-pressed", "false");
await expect(page.locator(".location-map-sheet-header strong")).toHaveText("Map Details");
await expect(page.getByLabel("Map summary")).toBeVisible();
});
test("mobile fit zoom fits the map into the visible canvas", async ({ page }) => {