Skip to content
Merged
Changes from 1 commit
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
Next Next commit
Site Editor: Fix document actions label helper method
  • Loading branch information
Mamaduka committed Aug 9, 2023
commit 847d3e9f2336582daebc74c8b3a4de8590a2eac3
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { sprintf, __, isRTL } from '@wordpress/i18n';
import { __, isRTL } from '@wordpress/i18n';
import { useSelect, useDispatch } from '@wordpress/data';
import {
Button,
Expand Down Expand Up @@ -118,8 +118,6 @@ function TemplateDocumentActions( { className, onBack } ) {
);
}

const entityLabel = getEntityLabel( record.type );

let typeIcon = icon;
if ( record.type === 'wp_navigation' ) {
typeIcon = navigationIcon;
Expand All @@ -137,11 +135,7 @@ function TemplateDocumentActions( { className, onBack } ) {
onBack={ onBack }
>
<VisuallyHidden as="span">
{ sprintf(
/* translators: %s: the entity being edited, like "template"*/
__( 'Editing %s: ' ),
entityLabel
) }
{ getEntityLabel( record.type ) }
</VisuallyHidden>
{ getTitle() }
</BaseDocumentActions>
Expand Down Expand Up @@ -189,18 +183,12 @@ function BaseDocumentActions( { className, icon, children, onBack } ) {
}

function getEntityLabel( entityType ) {
let label = '';
switch ( entityType ) {
case 'wp_navigation':
label = 'navigation menu';
break;
case 'wp_template_part':
label = 'template part';
break;
default:
label = 'template';
break;
}

return label;
const labels = {
wp_block: __( 'Editing pattern:' ),
wp_navigation: __( 'Editing navigation menu:' ),
wp_template: __( 'Editing template:' ),
wp_template_part: __( 'Editing template part:' ),
};

return labels[ entityType ] ?? labels.wp_template;
Copy link
Contributor

Choose a reason for hiding this comment

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

Because the default is template part when you edit a Page the title is not about editing a page but about editing a template part

Screen Shot 2023-07-27 at 16 20 05

Copy link
Member Author

Choose a reason for hiding this comment

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

@getdave, I think you're looking at the wrong label in a11y tree. The pages use a different Actions component, which doesn't use this helper.

Screenshot

CleanShot 2023-07-27 at 22 35 43

}