From d3d974f7ccb91be55590148b6bde6790820dd97e Mon Sep 17 00:00:00 2001 From: ViniciusCestarii Date: Wed, 19 Jun 2024 14:26:43 -0300 Subject: [PATCH 1/3] feat: add role region to div tag when aria: true --- src/visual/aria.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/visual/aria.ts b/src/visual/aria.ts index fae8999877..da4f6b3874 100644 --- a/src/visual/aria.ts +++ b/src/visual/aria.ts @@ -154,6 +154,7 @@ export default function ariaVisual(ecModel: GlobalModel, api: ExtensionAPI) { } if (labelModel.get('description')) { + dom.setAttribute('role', 'region'); dom.setAttribute('aria-label', labelModel.get('description')); return; } @@ -241,6 +242,7 @@ export default function ariaVisual(ecModel: GlobalModel, api: ExtensionAPI) { const endSeparator = separatorModel.get('end'); ariaLabel += seriesLabels.join(middleSeparator) + endSeparator; + dom.setAttribute('role', 'region'); dom.setAttribute('aria-label', ariaLabel); } } From b15b918b13ea2316025a98ab0d296db75750f5ce Mon Sep 17 00:00:00 2001 From: ViniciusCestarii Date: Thu, 20 Jun 2024 09:17:31 -0300 Subject: [PATCH 2/3] fix: change ARIA role from region to img for accessibility --- src/visual/aria.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/visual/aria.ts b/src/visual/aria.ts index da4f6b3874..c19071d187 100644 --- a/src/visual/aria.ts +++ b/src/visual/aria.ts @@ -154,7 +154,7 @@ export default function ariaVisual(ecModel: GlobalModel, api: ExtensionAPI) { } if (labelModel.get('description')) { - dom.setAttribute('role', 'region'); + dom.setAttribute('role', 'img'); dom.setAttribute('aria-label', labelModel.get('description')); return; } @@ -242,7 +242,7 @@ export default function ariaVisual(ecModel: GlobalModel, api: ExtensionAPI) { const endSeparator = separatorModel.get('end'); ariaLabel += seriesLabels.join(middleSeparator) + endSeparator; - dom.setAttribute('role', 'region'); + dom.setAttribute('role', 'img'); dom.setAttribute('aria-label', ariaLabel); } } From 64539fed9d35d0bb1ebc4a22fbcfb6cd6e219ae8 Mon Sep 17 00:00:00 2001 From: ViniciusCestarii Date: Fri, 21 Jun 2024 08:11:32 -0300 Subject: [PATCH 3/3] refactor: move dom.setAttribute('role', 'img') to reduce duplication --- src/visual/aria.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/visual/aria.ts b/src/visual/aria.ts index c19071d187..a184776274 100644 --- a/src/visual/aria.ts +++ b/src/visual/aria.ts @@ -153,8 +153,9 @@ export default function ariaVisual(ecModel: GlobalModel, api: ExtensionAPI) { return; } + dom.setAttribute('role', 'img'); + if (labelModel.get('description')) { - dom.setAttribute('role', 'img'); dom.setAttribute('aria-label', labelModel.get('description')); return; } @@ -242,7 +243,6 @@ export default function ariaVisual(ecModel: GlobalModel, api: ExtensionAPI) { const endSeparator = separatorModel.get('end'); ariaLabel += seriesLabels.join(middleSeparator) + endSeparator; - dom.setAttribute('role', 'img'); dom.setAttribute('aria-label', ariaLabel); } }