From 6dfed256dace00c6e3a1433911e984af2ac0a943 Mon Sep 17 00:00:00 2001 From: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Date: Mon, 10 Jul 2023 14:25:24 +0900 Subject: [PATCH] Patterns: Add missing decoding entities processing in Patterns and Template/Parts pages (#52449) --- .../src/components/page-patterns/use-patterns.js | 3 ++- .../src/components/template-actions/index.js | 3 ++- .../components/template-actions/rename-menu-item.js | 13 ++++++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/edit-site/src/components/page-patterns/use-patterns.js b/packages/edit-site/src/components/page-patterns/use-patterns.js index 0bcc52c85cb62..ea2b8ac976fea 100644 --- a/packages/edit-site/src/components/page-patterns/use-patterns.js +++ b/packages/edit-site/src/components/page-patterns/use-patterns.js @@ -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 @@ -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, } ); diff --git a/packages/edit-site/src/components/template-actions/index.js b/packages/edit-site/src/components/template-actions/index.js index b4618dcae966d..6e744135df67f 100644 --- a/packages/edit-site/src/components/template-actions/index.js +++ b/packages/edit-site/src/components/template-actions/index.js @@ -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 @@ -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', diff --git a/packages/edit-site/src/components/template-actions/rename-menu-item.js b/packages/edit-site/src/components/template-actions/rename-menu-item.js index cee30e64e99f2..9c6368ced17bf 100644 --- a/packages/edit-site/src/components/template-actions/rename-menu-item.js +++ b/packages/edit-site/src/components/template-actions/rename-menu-item.js @@ -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 { @@ -69,12 +73,7 @@ export default function RenameMenuItem( { template, onClose } ) { return ( <> - { - setIsModalOpen( true ); - setTitle( template.title.rendered ); - } } - > + setIsModalOpen( true ) }> { __( 'Rename' ) } { isModalOpen && (