-
Notifications
You must be signed in to change notification settings - Fork 840
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update
EuiScreenReaderLive
and use it in EUI Docs to announce page …
…loads to screen readers (#5995) * Adding focus control to EuiScreenReaderLive * Updating screen_reader_live to accept focus. * Added two tests for isFocusable behavior. * Adding documentation for isFocusable prop. * Updating skip link tests. * Adding CHANGELOG entry. * Splitting useEffects, making skip link color dynamic. * Fix toggle announcing too much on sub section link clicks * Improve subsection links screen reader experience * Updating one test after in-page link improvement. * Renaming a prop in unit tests. * misc tweaks/fixes to previous constance commits - actually revert guide_page_chrome to original code - fix scroll_to_hash comments, syntax * [PR feedback] EuiSkipLink `color` prop - DRY out ButtonColor typing - remove unnecessary `= 'primary'` fallback - EuiButton already has this by default, so passing undefined is fine * [PR feedback] Revert EuiSkipLink changes - the component already extends `EuiButtonProps` and already accepts `color` with all the necessary typing, which I only just realized 🤦 * Update src-docs/src/views/accessibility/accessibility_example.js Co-authored-by: Constance <constancecchen@users.noreply.github.com> * Update src/components/accessibility/screen_reader_live/screen_reader_live.tsx Co-authored-by: Constance <constancecchen@users.noreply.github.com> * Add documentation section for `focusRegionOnTextChange` + example * Messed up a snippet * Fix documentation example on small screens Co-authored-by: Constance Chen <constance.chen.3@gmail.com> Co-authored-by: Constance <constancecchen@users.noreply.github.com>
- Loading branch information
1 parent
48db5bb
commit 6e72317
Showing
9 changed files
with
218 additions
and
10 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
63 changes: 63 additions & 0 deletions
63
src-docs/src/views/accessibility/screen_reader_live_focus.tsx
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,63 @@ | ||
import React, { useState } from 'react'; | ||
|
||
import { | ||
EuiScreenReaderLive, | ||
EuiPageTemplate, | ||
EuiSideNav, | ||
EuiButton, | ||
} from '../../../../src/components'; | ||
import { htmlIdGenerator } from '../../../../src/services'; | ||
|
||
export default () => { | ||
const idGenerator = htmlIdGenerator('focusRegionOnTextChange'); | ||
|
||
const [pageTitle, setPageTitle] = useState('Home'); | ||
|
||
const sideNav = [ | ||
{ | ||
name: 'Example side nav', | ||
id: idGenerator(), | ||
items: [ | ||
{ | ||
name: 'Home', | ||
id: idGenerator(), | ||
onClick: () => setPageTitle('Home'), | ||
}, | ||
{ | ||
name: 'About', | ||
id: idGenerator(), | ||
onClick: () => setPageTitle('About'), | ||
}, | ||
{ | ||
name: 'Docs', | ||
id: idGenerator(), | ||
onClick: () => setPageTitle('Docs'), | ||
}, | ||
{ | ||
name: 'Contact', | ||
id: idGenerator(), | ||
onClick: () => setPageTitle('Contact'), | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
return ( | ||
<> | ||
<EuiPageTemplate | ||
pageSideBar={<EuiSideNav items={sideNav} isOpenOnMobile />} | ||
pageHeader={{ | ||
iconType: 'logoElastic', | ||
pageTitle: pageTitle, | ||
}} | ||
> | ||
<EuiScreenReaderLive focusRegionOnTextChange> | ||
{pageTitle} | ||
</EuiScreenReaderLive> | ||
<EuiButton> | ||
Clicking a nav link and then pressing tab should focus this button | ||
</EuiButton> | ||
</EuiPageTemplate> | ||
</> | ||
); | ||
}; |
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
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
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 @@ | ||
- Added `focusRegionOnTextChange` prop to `EuiScreenReaderLive` |