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 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
19 changes: 13 additions & 6 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 All @@ -31,7 +32,7 @@ import {
BottomSheet,
Picker,
} from '@wordpress/block-editor';
import { __, sprintf } from '@wordpress/i18n';
import { __ } from '@wordpress/i18n';
import { isURL } from '@wordpress/url';
import { doAction, hasAction } from '@wordpress/hooks';

Expand Down Expand Up @@ -254,7 +255,7 @@ class ImageEdit extends React.Component {
const toolbarEditButton = (
<Toolbar>
<ToolbarButton
label={ __( 'Edit image' ) }
title={ __( 'Edit image' ) }
icon="edit"
onClick={ onMediaOptionsButtonPressed }
/>
Expand Down Expand Up @@ -330,9 +331,8 @@ class ImageEdit extends React.Component {
return (
<TouchableWithoutFeedback
accessible={ ! isSelected }
accessibilityLabel={ sprintf( '%s%s %s', __( 'Image block' ), __( '.' ), alt ) }
accessibilityLabel={ __( 'Image block' ) + __( '.' ) + ' ' + alt + __( '.' ) + ' ' + caption }
accessibilityRole={ 'button' }
accessibilityHint={ __( 'Double tap to edit the image' ) }
onPress={ this.onImagePressed }
disabled={ ! isSelected }
>
Expand All @@ -343,7 +343,7 @@ class ImageEdit extends React.Component {
</BlockControls>
<InspectorControls>
<ToolbarButton
label={ __( 'Image Settings' ) }
title={ __( 'Image Settings' ) }
icon="admin-generic"
onClick={ onImageSettingsButtonPressed }
/>
Expand Down Expand Up @@ -377,6 +377,8 @@ class ImageEdit extends React.Component {
resizeMethod="scale"
source={ { uri: url } }
key={ url }
accessible={ true }
accessibilityLabel={ alt }
>
{ this.state.isUploadFailed &&
<View style={ styles.imageContainer } >
Expand All @@ -390,7 +392,12 @@ 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 ) }
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