-
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
Template actions with DropDownMenuV2 #51043
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 |
---|---|---|
|
@@ -15,7 +15,11 @@ import { | |
import { store as coreStore } from '@wordpress/core-data'; | ||
import { store as noticesStore } from '@wordpress/notices'; | ||
|
||
export default function RenameMenuItem( { template, onClose } ) { | ||
export default function RenameMenuItem( { | ||
template, | ||
onClose, | ||
as: UsedComponent = MenuItem, | ||
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. Any reason why we're not using |
||
} ) { | ||
const [ title, setTitle ] = useState( () => template.title.rendered ); | ||
const [ isModalOpen, setIsModalOpen ] = useState( false ); | ||
|
||
|
@@ -64,14 +68,14 @@ export default function RenameMenuItem( { template, onClose } ) { | |
|
||
return ( | ||
<> | ||
<MenuItem | ||
<UsedComponent | ||
onClick={ () => { | ||
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'm not sure if |
||
setIsModalOpen( true ); | ||
setTitle( template.title.rendered ); | ||
} } | ||
> | ||
{ __( 'Rename' ) } | ||
</MenuItem> | ||
</UsedComponent> | ||
{ isModalOpen && ( | ||
<Modal | ||
title={ __( 'Rename' ) } | ||
|
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.
DropdownMenuItemV2
doesn't expose aninfo
prop — you'll have to usechildren
and add/style that text separately