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 committed Jul 10, 2023
1 parent b6ac42a commit 6dfed25
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 {
Expand Down Expand Up @@ -69,12 +73,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

1 comment on commit 6dfed25

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in 6dfed25.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5504401545
📝 Reported issues:

Please sign in to comment.