Skip to content

Commit

Permalink
fix: Change aria-label depending on content of paragraph block (#11653)
Browse files Browse the repository at this point in the history
* fix: Only show aria-label when content is empty

Fix issue introduced in #11560

* Improve aria labels so they reflect state of block/empty block
  • Loading branch information
tofumatt authored and youknowriad committed Nov 9, 2018
1 parent 6d6b849 commit eba8b7f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/design/block-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ The most basic unit of the editor. The paragraph block is a simple input field.

### Placeholder:

- Simple placeholder text that reads “Start writing or press / to insert a block”. The placeholder disappears when the block is selected.
- Simple placeholder text that reads “Start writing or type / to choose a block”. The placeholder disappears when the block is selected.

### Selected state:

Expand Down
2 changes: 1 addition & 1 deletion lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,7 @@ function gutenberg_editor_scripts_and_styles( $hook ) {
'disableCustomFontSizes' => get_theme_support( 'disable-custom-font-sizes' ),
'disablePostFormats' => ! current_theme_supports( 'post-formats' ),
'titlePlaceholder' => apply_filters( 'enter_title_here', __( 'Add title', 'gutenberg' ), $post ),
'bodyPlaceholder' => apply_filters( 'write_your_story', __( 'Start writing or press / to insert a block', 'gutenberg' ), $post ),
'bodyPlaceholder' => apply_filters( 'write_your_story', __( 'Start writing or type / to choose a block', 'gutenberg' ), $post ),
'isRTL' => is_rtl(),
'autosaveInterval' => 10,
'maxUploadFileSize' => $max_upload_size,
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/paragraph/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ class ParagraphBlock extends Component {
onMerge={ mergeBlocks }
onReplace={ this.onReplace }
onRemove={ () => onReplace( [] ) }
aria-label={ __( 'Empty block; type text or press the forward slash key to insert a block' ) }
placeholder={ placeholder || __( 'Start writing or press / to insert a block' ) }
aria-label={ content ? __( 'Paragraph block' ) : __( 'Empty block; start writing or type forward slash to choose a block' ) }
placeholder={ placeholder || __( 'Start writing or type / to choose a block' ) }
/>
</Fragment>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ exports[`core/paragraph block edit matches snapshot 1`] = `
<p
aria-autocomplete="list"
aria-expanded="false"
aria-label="Empty block; type text or press the forward slash key to insert a block"
aria-label="Empty block; start writing or type forward slash to choose a block"
aria-multiline="true"
class="wp-block-paragraph editor-rich-text__tinymce"
contenteditable="true"
Expand All @@ -28,7 +28,7 @@ exports[`core/paragraph block edit matches snapshot 1`] = `
<p
class="editor-rich-text__tinymce wp-block-paragraph"
>
Start writing or press / to insert a block
Start writing or type / to choose a block
</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function DefaultBlockAppender( {
return null;
}

const value = decodeEntities( placeholder ) || __( 'Start writing or press / to insert a block' );
const value = decodeEntities( placeholder ) || __( 'Start writing or type / to choose a block' );

// The appender "button" is in-fact a text field so as to support
// transitions by WritingFlow occurring by arrow key press. WritingFlow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exports[`DefaultBlockAppender should append a default block when input focused 1
readOnly={true}
role="button"
type="text"
value="Start writing or press / to insert a block"
value="Start writing or type / to choose a block"
/>
<WithSelect(WithDispatch(InserterWithShortcuts)) />
<WithSelect(IfCondition(Inserter))
Expand All @@ -42,7 +42,7 @@ exports[`DefaultBlockAppender should match snapshot 1`] = `
readOnly={true}
role="button"
type="text"
value="Start writing or press / to insert a block"
value="Start writing or type / to choose a block"
/>
<WithSelect(WithDispatch(InserterWithShortcuts)) />
<WithSelect(IfCondition(Inserter))
Expand Down

0 comments on commit eba8b7f

Please sign in to comment.