fix: announce map area item counts

This commit is contained in:
Nico 2026-06-04 21:46:59 -07:00
parent 1ab359d343
commit 95afcf3978
2 changed files with 7 additions and 3 deletions

View File

@ -54,14 +54,16 @@ export default function LocationMapObject({
const key = getObjectKey(object);
const displayLabel = getMapObjectDisplayLabel(object, index + 1);
const accessibleLabel = canEditObjects && object.locked
? `Map area ${displayLabel}, locked`
: `Map area ${displayLabel}`;
const count = zoneItems.length;
const hasHiddenZoneItems = assignedZoneItemCount > count;
const countLabel = hasHiddenZoneItems
? `${count} shown`
: `${count} item${count === 1 ? "" : "s"}`;
const accessibleLabel = canEditObjects
? object.locked
? `Map area ${displayLabel}, locked`
: `Map area ${displayLabel}`
: `Map area ${displayLabel}, ${countLabel}`;
const labelLines = fittedLabelLines(object, "Area");
const countY = filters.showLabels && labelLines.length > 1 ? object.y + 76 : object.y + 52;
const resizeHandleSize = Math.min(96, Math.max(44, Math.ceil(48 / zoom)));

View File

@ -3806,6 +3806,8 @@ test("viewer map areas are keyboard selectable", async ({ page }) => {
const bakeryArea = page.getByRole("button", { name: "Map area Bakery" });
const frozenArea = page.getByRole("button", { name: "Map area Frozen Foods" });
const bakeryRect = page.locator('[data-object-key="1571"]').locator("rect").first();
await expect(page.getByRole("button", { name: "Map area Bakery, 2 items", exact: true })).toBeVisible();
await expect(page.getByRole("button", { name: "Map area Frozen Foods, 0 shown", exact: true })).toBeVisible();
await expect(bakeryArea).toHaveAttribute("aria-pressed", "false");
const initialFill = await bakeryRect.evaluate((element) => getComputedStyle(element).fill);