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]Improve accessibility on image block selected state #15122

Merged
merged 6 commits into from
Apr 24, 2019
Merged
Changes from 3 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
17 changes: 14 additions & 3 deletions packages/block-library/src/image/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
requestImageFailedRetryDialog,
requestImageUploadCancelDialog,
} from 'react-native-gutenberg-bridge';
import { isEmpty } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -254,9 +255,10 @@ class ImageEdit extends React.Component {
const toolbarEditButton = (
<Toolbar>
<ToolbarButton
label={ __( 'Edit image' ) }
title={ __( 'Edit image' ) }
icon="edit"
onClick={ onMediaOptionsButtonPressed }
extraProps={ { hint: __( 'Double tap to edit image' ) } }
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think that the hint here is adding new information, so it's probably not needed.

/>
</Toolbar>
);
Expand Down Expand Up @@ -343,9 +345,10 @@ class ImageEdit extends React.Component {
</BlockControls>
<InspectorControls>
<ToolbarButton
label={ __( 'Image Settings' ) }
title={ __( 'Image Settings' ) }
icon="admin-generic"
onClick={ onImageSettingsButtonPressed }
extraProps={ { hint: __( 'Double tap to open image settings' ) } }
/>
</InspectorControls>
<ImageSize src={ url } >
Expand Down Expand Up @@ -377,6 +380,8 @@ class ImageEdit extends React.Component {
resizeMethod="scale"
source={ { uri: url } }
key={ url }
accessible={ true }
accessibilityLabel={ __( 'Image' ) + __( '.' ) + ' ' + alt }
Copy link
Contributor

Choose a reason for hiding this comment

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

Good call! sprintf is not really necessary to add an extra space 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

On this particular case, I think the Image prefix is not necessary.
ImageBackground component uses an Image component internally that is already marked as an Image accessibility item. This makes VoiceOver read Image at the end, so it currently reads "Image. {Alt}. Image".

I'd say let's just add the Alt as label so it reads "{Alt}. Image".

>
{ this.state.isUploadFailed &&
<View style={ styles.imageContainer } >
Expand All @@ -390,7 +395,13 @@ class ImageEdit extends React.Component {
} }
</ImageSize>
{ ( ! RichText.isEmpty( caption ) > 0 || isSelected ) && (
<View style={ { padding: 12, flex: 1 } }>
<View
style={ { padding: 12, flex: 1 } }
accessible={ true }
accessibilityLabel={ __( 'Image caption' ) + __( '.' ) + ' ' + ( isEmpty( caption ) ? __( 'Empty' ) : caption ) }
accessibilityHint={ __( 'Double tap to edit caption' ) }
accessibilityRole={ 'button' }
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if the hint is really necessary here. Is true that from the label, it's not obvious that this can be edited, but as is marked as a button it denotes that it's actionable. After the action the user gets in the text field on edit mode.

If we keep it, I'd add a the between edit and caption (Double tap to edit the caption). But better to ask someone English native to be sure :)

>
<TextInput
style={ { textAlign: 'center' } }
fontFamily={ this.props.fontFamily || ( styles[ 'caption-text' ].fontFamily ) }
Expand Down