Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add optional prop to set aria-label on OL canvas element in shadow root #445

Merged
merged 3 commits into from
Apr 10, 2024

Conversation

jessicamcinchak
Copy link
Member

@jessicamcinchak jessicamcinchak commented Apr 8, 2024

Adds an optional string prop ariaLabelOlFixedOverlay which sets an aria-label on the canvas element rendered in the shadow root.

Per page 98 of recent audit:

The map feature on the page does not have an accessible name. This instance can be found
with the canvas below the ‘about the property’ heading. The map has been written with an
appropriate element, however the element is missing an accessible name, meaning that
screen reader users get relayed the text ‘basemap subject to crown copyright…’, which does
not provide these users with information that is presented visually.

Solution:
As the map contains a focusable element, consider adding an accessible name to the map
feature by adding an aria-label to the canvas.

References / possible gotchas:

Copy link

netlify bot commented Apr 8, 2024

Deploy Preview for oslmap ready!

Name Link
🔨 Latest commit b3807a0
🔍 Latest deploy log https://app.netlify.com/sites/oslmap/deploys/66150a3823fade0008de1ed6
😎 Deploy Preview https://deploy-preview-445--oslmap.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -629,6 +632,10 @@ export class MyMap extends LitElement {
});
}

// Add an aria-label to the overlay canvas for accessibility
const olCanvas = this.renderRoot?.querySelector("canvas.ol-fixedoverlay");
Copy link
Member Author

@jessicamcinchak jessicamcinchak Apr 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's two canvas elements rendered by OL in the shadow root, but I've only been able to successfully select this one - which does differ than the code reference given in our report:

Current code ref(s):
#property-information-map > div > div.ol-unselectable.ol-layers > div:nth-child(2) > canvas

So,

  • Am I missing something obvious to be able to select the .ol-unselectable .ol-layers canvas element?
  • If that canvas is actually unselectable, are we still happy applying this proposed fix to this canvas and seeing how it re-tests?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good point to flag and I think I know why you're getting inconsistent results.

My understanding is that OpenLayers doesn't generate either a single canvas, or canvas per-layer, but rather adds additional canvases as needed for memory/rendering.

I'm trying to find some sort of reference to this online and nothing yet to confirm this in writing!

Looking through OpenLayers examples and inspecting the DOM you can see maps with multiple layers on a single canvas, and some spread over multiple canvases.

What might be best here is trying to select all canvas elements (querySelectorAll() I think) and appending ${ariaLabelOlFixedOverlay}-${i}?

Copy link
Member Author

@jessicamcinchak jessicamcinchak Apr 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dev call resolution here:

  • We don't want to label all & overread (even if we could successfully select all)
  • By targeting fixedoverlay, we are targetting the outermost canvas which will hopefully still achieve same result as original suggestion
  • It's a usability issue, not A-level - so let's keep it timeboxed!

@jessicamcinchak
Copy link
Member Author

@jessicamcinchak jessicamcinchak marked this pull request as ready for review April 8, 2024 18:30
@jessicamcinchak jessicamcinchak requested a review from a team April 8, 2024 18:30
Copy link
Contributor

@DafyddLlyr DafyddLlyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I noticed is that the old ariaLabel prop is still mentioned in the Pitsby docs, so it's worth trying to update this at the same time here I think.

image

@@ -629,6 +632,10 @@ export class MyMap extends LitElement {
});
}

// Add an aria-label to the overlay canvas for accessibility
const olCanvas = this.renderRoot?.querySelector("canvas.ol-fixedoverlay");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good point to flag and I think I know why you're getting inconsistent results.

My understanding is that OpenLayers doesn't generate either a single canvas, or canvas per-layer, but rather adds additional canvases as needed for memory/rendering.

I'm trying to find some sort of reference to this online and nothing yet to confirm this in writing!

Looking through OpenLayers examples and inspecting the DOM you can see maps with multiple layers on a single canvas, and some spread over multiple canvases.

What might be best here is trying to select all canvas elements (querySelectorAll() I think) and appending ${ariaLabelOlFixedOverlay}-${i}?

src/components/my-map/index.ts Show resolved Hide resolved
@jessicamcinchak jessicamcinchak merged commit b624c07 into main Apr 10, 2024
5 checks passed
@jessicamcinchak jessicamcinchak deleted the jess/aria-label-ol-canvas branch April 10, 2024 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants