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

Accessibility: Improve Welcome guide and modal component. #19261

Merged
merged 1 commit into from
Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/components/src/guide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ A custom class to add to the modal.
- Type: `string`
- Required: No

### contentLabel

This property is used as the modal's accessibility label. It is required for accessibility reasons.

- Type: `String`
- Required: Yes

### finishButtonText

Use this to customize the label of the _Finish_ button shown at the end of the guide.
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/guide/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import PageControl from './page-control';
import { BackButtonIcon, ForwardButtonIcon } from './icons';
import FinishButton from './finish-button';

export default function Guide( { children, className, finishButtonText, onFinish } ) {
export default function Guide( { children, className, contentLabel, finishButtonText, onFinish } ) {
const [ currentPage, setCurrentPage ] = useState( 0 );

const numberOfPages = Children.count( children );
Expand All @@ -45,6 +45,7 @@ export default function Guide( { children, className, finishButtonText, onFinish
return (
<Modal
className={ classnames( 'components-guide', className ) }
contentLabel={ contentLabel }
onRequestClose={ onFinish }
>

Expand Down
5 changes: 4 additions & 1 deletion packages/components/src/guide/page-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ export default function PageControl( { currentPage, numberOfPages, setCurrentPag
return (
<ul className="components-guide__page-control" aria-label={ __( 'Guide controls' ) }>
{ times( numberOfPages, ( page ) => (
<li key={ page }>
<li
key={ page }
aria-current={ page === currentPage }
>
<IconButton
key={ page }
icon={ <PageControlIcon isSelected={ page === currentPage } /> }
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/guide/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ const ModalExample = ( { numberOfPages, ...props } ) => {

export const _default = () => {
const finishButtonText = text( 'finishButtonText', 'Finish' );
const contentLabel = text( 'title', 'Guide title' );
const numberOfPages = number( 'numberOfPages', 3, { range: true, min: 1, max: 10, step: 1 } );

const modalProps = {
finishButtonText,
contentLabel,
numberOfPages,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class Modal extends Component {
} }
{ ...otherProps }
>
<div className={ 'components-modal__content' } tabIndex="0">
<div className={ 'components-modal__content' } tabIndex="0" role="document">
<ModalHeader
closeLabel={ closeButtonLabel }
headingId={ headingId }
Expand Down
1 change: 1 addition & 0 deletions packages/edit-post/src/components/welcome-guide/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default function WelcomeGuide() {
return (
<Guide
className="edit-post-welcome-guide"
contentLabel={ __( 'Welcome to the Block Editor' ) }
finishButtonText={ __( 'Get started' ) }
onFinish={ () => toggleFeature( 'welcomeGuide' ) }
>
Expand Down