-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Patterns: Add missing decoding entities processing in Patterns and Template/Parts pages #52449
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 ( | ||
<> | ||
<MenuItem | ||
onClick={ () => { | ||
setIsModalOpen( true ); | ||
setTitle( template.title.rendered ); | ||
} } | ||
> | ||
<MenuItem onClick={ () => setIsModalOpen( true ) }> | ||
Comment on lines
-72
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there is no need to call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this was set in #36879 so that unsaved changes wouldn't persist when closing and reopening the modal. It's a bit of an edge case, but if you make changes, click cancel, and then click "rename" again (without closing and reopening the parent menu of the "rename" button), you'll see the unsaved changes have been kept. |
||
{ __( 'Rename' ) } | ||
</MenuItem> | ||
{ isModalOpen && ( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decoding here eliminates the need for separate decoding in the lower-layer components. This is consistent with the fact that
reusableBlockToPattern
in the same file usestitle.raw
as the value of the title property.