From 6bfe3d639348c47f7f0a132d16de05c204a41a7f Mon Sep 17 00:00:00 2001 From: Ian Jones Date: Wed, 8 May 2024 15:37:45 +0100 Subject: [PATCH] fix(a11y): Add aria-controls to attribution toggle and list --- src/components/my-map/index.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/components/my-map/index.ts b/src/components/my-map/index.ts index 63e7b87e..e09ceb4c 100644 --- a/src/components/my-map/index.ts +++ b/src/components/my-map/index.ts @@ -367,6 +367,18 @@ export class MyMap extends LitElement { node.setAttribute("aria-label", node.getAttribute("title") || ""), ); + // Apply aria-controls to attribution button for accessibility + const olAttributionButton: NodeListOf | undefined = + this.renderRoot?.querySelectorAll(".ol-attribution button"); + olAttributionButton?.forEach((node) => + node.setAttribute("aria-controls", "ol-attribution-list"), + ); + + // Apply ID to attribution list for accessibility + const olList: NodeListOf | undefined = + this.renderRoot?.querySelectorAll(".ol-attribution ul"); + olList?.forEach((node) => node.setAttribute("id", "ol-attribution-list")); + // Re-order overlay elements so that OL Attribution is final element // making OL Controls first in natural tab order for accessibility const olAttribution = this.renderRoot?.querySelector(