Skip to content
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

Button Block: Add draft page creation capability #69368

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

dhruvikpatel18
Copy link
Contributor

@dhruvikpatel18 dhruvikpatel18 commented Feb 28, 2025

Closes #56163

What?

This PR adds the ability to create draft pages directly from the button block in the navigation editor, similar to how it already works in the navigation link block.

Why?

Currently, users can create a draft page from the custom link block in the navigation editor if the page doesn't exist, but this functionality isn't available in the button block. This PR addresses this inconsistency by implementing the same feature in the button block, providing a more consistent editing experience.

How?

  1. Adds draft page creation functionality to the button block's LinkControl component
  2. Imports necessary components and utilities from WordPress core
  3. Adds permission checks to control when the draft creation feature is available
  4. Uses the same pattern already implemented in the navigation link block

Testing Instructions

  1. Create a new post or page
  2. Insert a navigation block
  3. Add a button block to the navigation
  4. Click on the link icon in the toolbar to edit the link
  5. In the link search field, enter a page name that doesn't exist yet
  6. Verify that an option appears to "Create draft page: [your search term]"
  7. Click on this option and verify that a draft page is created and linked

Screenshots or screencast

Before

Screen.Recording.2025-02-28.at.2.21.54.PM.mov

After

Screen.Recording.2025-02-28.at.2.34.04.PM.mov

@dhruvikpatel18 dhruvikpatel18 marked this pull request as ready for review February 28, 2025 11:21
Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: dhruvikpatel18 <[email protected]>
Co-authored-by: ajlende <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Mamaduka Mamaduka added [Type] Enhancement A suggestion for improvement. [Block] Buttons Affects the Buttons Block labels Mar 4, 2025
Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

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

Thanks for contributing, @dhruvikpatel18!

I think we can reduce boilerplate code here by using the same approach as the Link format. See the InlineLinkUI component for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Buttons Affects the Buttons Block [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Add a draft page from button block in navigation
2 participants