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

[Mobile] Improving accessibility on Post title #15106

Merged
merged 6 commits into from
Apr 23, 2019
Merged
Changes from 2 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
8 changes: 7 additions & 1 deletion packages/editor/src/components/post-title/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import { View } from 'react-native';
import { isEmpty } from 'lodash';

/**
* WordPress dependencies
Expand All @@ -12,6 +13,7 @@ import { decodeEntities } from '@wordpress/html-entities';
import { withDispatch } from '@wordpress/data';
import { withFocusOutside } from '@wordpress/components';
import { withInstanceId, compose } from '@wordpress/compose';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
Expand Down Expand Up @@ -70,7 +72,11 @@ class PostTitle extends Component {
const borderColor = this.state.isSelected ? focusedBorderColor : 'transparent';

return (
<View style={ [ styles.titleContainer, borderStyle, { borderColor } ] }>
<View
style={ [ styles.titleContainer, borderStyle, { borderColor } ] }
accessible={ ! this.state.isSelected }
accessibilityLabel={ __( 'Post title' ) + '. ' + ( isEmpty( title ) ? __( 'Empty' ) : title ) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a quick note about this:

Although most languages use a period (.) to end a sentence, some don't, and we might think that it would be more correct to use sprintf in this case to concatenate the 2 sentences.

sprintf( __( 'Post title. %s' ), isEmpty( title ) ? __( 'Empty' ) : title )

However I don't think it's worth it at this point. it's not very clear for translators what the Post title. %s string means (even with a comment). Moreover Post title will probably be reused at other places so it makes more sense to translate that only.

Lastly, this sentence is built to be heard not read by the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating this according to what we discussed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! We can refer to this one for the future accessibility labels

>
<RichText
tagName={ 'p' }
rootTagsToEliminate={ [ 'strong' ] }
Expand Down