Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cd9a2ec

Browse files
committed
Document why we have this event and why you should use it
1 parent b81f184 commit cd9a2ec

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ fuzzyFilterInput.filter = (element, elementText, query) => {
101101
- `filter-input-start` (bubbles) - fired on `<filter-input>` when a filter action is about to start.
102102
- `filter-input-updated` (bubbles) - fired on `<filter-input>` when filter has finished. `event.detail.count` is the number of matches found, and `event.detail.total` is the total number of elements.
103103

104+
To ensure that the client side update is communicated to assistive technologies, `filter-input-updated` event can be used to update filter results to screen readers. For example:
105+
106+
```js
107+
const ariaLiveContainer = document.querySelector('[aria-live="assertive"]')
108+
document.addEventListener('filter-input-updated', event => {
109+
ariaLiveContainer.textContent = `${event.detail.count} results found.`
110+
})
111+
```
112+
113+
For more details on this technique, check out [Improving accessibility on GOV.UK search](https://technology.blog.gov.uk/2014/08/14/improving-accessibility-on-gov-uk-search/).
114+
104115
## Browser support
105116

106117
Browsers without native [custom element support][support] require a [polyfill][].

0 commit comments

Comments
 (0)