This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve accessibility of OgProgress, for #536
- Loading branch information
1 parent
241e754
commit 8b2564c
Showing
3 changed files
with
100 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<template> | ||
<span | ||
class="oc-visually-hidden" | ||
:id="id" | ||
:aria-live="level" | ||
aria-atomic="true" | ||
v-text="announcement" | ||
></span> | ||
</template> | ||
<script> | ||
/** | ||
* Live regions for screen reader announcements | ||
* | ||
* ## Accessibility | ||
* | ||
* Screen reader software detect **dynamic** changes in regions registered as live regions (elements with attributes like `aria-live="polite"`, `aria-live="assertive"`). So when using this component or live regions in general make sure that the region already exists in the DOM and assistive technology can subscribe to its changes. [MDN explainer](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions): | ||
* | ||
* > Using JavaScript, it is possible to dynamically change parts of a page without requiring the entire page to reload — for instance, to update a list of search results on the fly, or to display a discreet alert or notification which does not require user interaction. While these changes are usually visually apparent to users who can see the page, they may not be obvious to users of assistive technologies. ARIA live regions fill this gap and provide a way to programmatically expose dynamic content changes in a way that can be announced by assistive technologies. | ||
* | ||
* ## Debugging | ||
* | ||
* Debug live regions without starting a screen reader using [NerdeRegion](https://chrome.google.com/webstore/detail/nerderegion/lkcampbojgmgobcfinlkgkodlnlpjieb). | ||
*/ | ||
export default { | ||
name: "oc-hidden-announcer", | ||
status: "review", | ||
release: "1.0.0", | ||
data() { | ||
return { | ||
// Generate id for compatibility reasons | ||
id: | ||
Math.random() | ||
.toString(36) | ||
.substring(2, 15) + | ||
Math.random() | ||
.toString(36) | ||
.substring(2, 15), | ||
} | ||
}, | ||
props: { | ||
/** | ||
* `polite` adds the announcement to the screen reader speech queue at the end, `assertive` forces it to output directly, `off` disables the live region | ||
**/ | ||
level: { | ||
type: String, | ||
required: false, | ||
default: "polite", | ||
}, | ||
/** | ||
* The announcement text itself. | ||
**/ | ||
announcement: { | ||
type: String, | ||
required: true, | ||
default: "", | ||
}, | ||
}, | ||
} | ||
</script> | ||
<docs> | ||
```jsx | ||
<script> | ||
export default { | ||
data: () => { | ||
return { | ||
announcement: '', | ||
announcementOnComplete: 'Upload has finished' | ||
} | ||
}, | ||
methods: { | ||
announce() { | ||
this.announcement = this.announcementOnComplete | ||
} | ||
} | ||
} | ||
</script> | ||
<template> | ||
<div> | ||
<h3 class="uk-heading-divider"> | ||
Hidden announcer (please inspect element) | ||
</h3> | ||
<button @click="announce">Announce</button> | ||
<oc-hidden-announcer level="polite" :announcement="announcement" /> | ||
</div> | ||
</template> | ||
``` | ||
</docs> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters