Skip to content

Commit

Permalink
Patterns: Add missing decoding entities processing in Patterns and Te…
Browse files Browse the repository at this point in the history
…mplate/Parts pages (#52449)
  • Loading branch information
t-hamano authored and tellthemachines committed Jul 10, 2023
1 parent 509fcf3 commit 1219af6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Expand Up @@ -4,6 +4,7 @@
import { parse } from '@wordpress/blocks';
import { useSelect } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';
import { decodeEntities } from '@wordpress/html-entities';

/**
* Internal dependencies
Expand Down Expand Up @@ -33,7 +34,7 @@ const templatePartToPattern = ( templatePart ) => ( {
keywords: templatePart.keywords || [],
id: createTemplatePartId( templatePart.theme, templatePart.slug ),
name: createTemplatePartId( templatePart.theme, templatePart.slug ),
title: templatePart.title.rendered,
title: decodeEntities( templatePart.title.rendered ),
type: templatePart.type,
templatePart,
} );
Expand Down
3 changes: 2 additions & 1 deletion packages/edit-site/src/components/template-actions/index.js
Expand Up @@ -13,6 +13,7 @@ import {
} from '@wordpress/components';
import { moreVertical } from '@wordpress/icons';
import { store as noticesStore } from '@wordpress/notices';
import { decodeEntities } from '@wordpress/html-entities';

/**
* Internal dependencies
Expand Down Expand Up @@ -58,7 +59,7 @@ export default function TemplateActions( {
sprintf(
/* translators: The template/part's name. */
__( '"%s" reverted.' ),
template.title.rendered
decodeEntities( template.title.rendered )
),
{
type: 'snackbar',
Expand Down
Expand Up @@ -14,9 +14,13 @@ import {
} from '@wordpress/components';
import { store as coreStore } from '@wordpress/core-data';
import { store as noticesStore } from '@wordpress/notices';
import { decodeEntities } from '@wordpress/html-entities';

export default function RenameMenuItem( { template, onClose } ) {
const [ title, setTitle ] = useState( () => template.title.rendered );
const [ title, setTitle ] = useState(
decodeEntities( template.title.rendered )
);

const [ isModalOpen, setIsModalOpen ] = useState( false );

const { editEntityRecord, saveEditedEntityRecord } =
Expand Down Expand Up @@ -64,12 +68,7 @@ export default function RenameMenuItem( { template, onClose } ) {

return (
<>
<MenuItem
onClick={ () => {
setIsModalOpen( true );
setTitle( template.title.rendered );
} }
>
<MenuItem onClick={ () => setIsModalOpen( true ) }>
{ __( 'Rename' ) }
</MenuItem>
{ isModalOpen && (
Expand Down

0 comments on commit 1219af6

Please sign in to comment.