Skip to content

Commit f694a7f

Browse files
committed
docs: Add ARIA live regions
1 parent 39e9c62 commit f694a7f

File tree

1 file changed

+40
-51
lines changed

1 file changed

+40
-51
lines changed

README.md

Lines changed: 40 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ Imagine browsing pages (routes), receiving alerts and notifications, having a co
1111

1212
The [@vue-a11y/announcer@next](https://github.com/vue-a11y/vue-announcer/tree/next) (v3.*) for Vue 3 provides an easy way to really tell what’s going on in your application to people using screen readers.
1313

14-
> For vue-announcer version 2.* you can access [this link](https://github.com/vue-a11y/vue-announcer/tree/master)
15-
1614
## Links
1715
- [Demo](https://vue-announcer.surge.sh/)
16+
- [ARIA live regions](#aria-live-regions)
1817

1918
## Setup
2019

@@ -75,7 +74,7 @@ const { assertive } = useAnnouncer()
7574
const { polite } = useAnnouncer()
7675
```
7776

78-
### Change routeComplement
77+
## Change routeComplement
7978

8079
If you need to set the `routeComplement` option dynamically without reloading the application, for example if you're dynamically loading translations, you can use this method to update it.
8180

@@ -109,7 +108,7 @@ Key | Data Type | data | default |
109108
`politeness` | String | polite, assertive, off | `polite` |
110109
`complementRoute` | String | | `has loaded` |
111110

112-
### Custom announcer (object meta)
111+
## Custom announcer (object meta)
113112

114113
You can customize the message by defining the announcer on the "meta" object for each specific route.
115114

@@ -139,11 +138,11 @@ Key | Data Type | data | default
139138
`skip` | Boolean | | false |
140139
`routeComplement` | String | | `has loaded` or set at installation |
141140

142-
#### Note
141+
### Note
143142
- The plug-in checks whether the message to be announced has been defined in the meta.announcer object, otherwise the document title to be loaded will be announced.
144143
- The `@vue-a11y/announcer@next` uses the global after hooks `router.afterEach` to announce the route changes.
145144

146-
### Skip in specific route
145+
## Skip in specific route
147146
Necessary for dynamic content pages that require asynchronous data to compose the page title.
148147

149148
The skip property on the `meta.announcer` object is used to `skip` the automatic announcement made on the `router.afterEach`, that way you can announce when the asynchronous data is available.
@@ -153,7 +152,6 @@ For example:
153152
In you [`routes.js`](/demo/src/router/routes.ts)
154153

155154
```js
156-
// ...
157155
{
158156
name: 'post',
159157
path: '/posts/:id',
@@ -164,62 +162,53 @@ In you [`routes.js`](/demo/src/router/routes.ts)
164162
}
165163
}
166164
}
167-
// ...
168165
```
169166

170-
In you [`Post.vue`](/demo/src/pages/Post.vue)
167+
## ARIA live regions
171168

172-
```vue
173-
<template>
174-
<template v-if="post">
175-
<h2>{{ post.title }}</h2>
176-
<p>{{ post.body }}</p>
177-
</template>
178-
<template v-if="error">
179-
<h2 class="msg-error">{{ error }}</h2>
180-
</template>
181-
</template>
169+
"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.**"
182170

183-
<script lang="ts">
184-
import { defineComponent, ref } from 'vue'
185-
import { useAnnouncer } from '@vue-a11y/announcer'
186-
187-
export default defineComponent({
188-
name: 'Post',
189-
190-
setup () {
191-
const post: any = ref(null)
192-
const error: any = ref(null)
193-
const { polite, assertive } = useAnnouncer()
194-
195-
fetch(`https://jsonplaceholder.typicode.com/posts/1`)
196-
.then(res => {
197-
if (!res.ok) throw Error(res.statusText || "Error loading the post");
198-
return res.json();
199-
})
200-
.then(res => {
201-
post.value = { ...res };
202-
polite(`${post.value.title} page has loaded`);
203-
})
204-
.catch(e => {
205-
error.value = e.message;
206-
assertive(error.value);
207-
});
208-
209-
return { post, error }
210-
}
211-
})
212-
</script>
171+
--- [ARIA live regions - Accessibility | MDN](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions)
172+
173+
## Politeness settings
174+
175+
You can use the options `polite`, `assertive` and `off`, if no configuration is defined, the default is `off`.
176+
177+
### polite
178+
It is used in most situations that present new information to users.
179+
The notification will take place at the next available point, without interruptions.
180+
181+
---
182+
NOTE: `polite` is default
183+
184+
---
185+
186+
### assertive
187+
It is used in situations where the notification is important enough to communicate it immediately, for example, error messages or alerts.
188+
189+
190+
```javascript
191+
const { assertive } = useAnnouncer()
192+
assertive('My notification error')
213193
```
214194

215-
# Browser Testing
195+
### off
196+
Is the default and prevent assistive technology from keeping up with changes.
197+
198+
199+
### Referencies
200+
201+
- [ARIA live regions - Accessibility | MDN](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions)
202+
- [Using aria-live - Bitsofcode](https://bitsofco.de/using-aria-live/)
203+
204+
## Browser Testing
216205

217206
Vue Announcer was tested and works as expected in the latest versions of:
218207

219208
- NVDA (Chrome) ✔️
220209
- ChromeVox (Chrome extension) ✔️
221210

222-
## To test
211+
### To test
223212

224213
- Android TalkBack
225214
- JAWS

0 commit comments

Comments
 (0)