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

Fix: Navigation Block - Can't delete default custom links. #68782

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

Conversation

dhananjaykuber
Copy link
Contributor

Fixes #56387

What?

Add keyboard Delete handling to remove empty Navigation Link blocks.

Why?

Currently, when users add a new Navigation Link block, they get an empty custom link with "Add link" placeholder text. Users naturally expect to be able to delete this empty link using the Delete key, but this functionality is missing. This PR implements this expected behavior, improving the user experience and making the Navigation block behavior more intuitive.

How?

  • Extended the existing onKeyDown handler in NavigationLinkEdit component
  • Added logic to detect Delete key events
  • Implemented deletion only for empty links (no URL and no label) to prevent accidental deletions
    Utilized existing onReplace([]) mechanism for block removal

Testing Instructions

Testing Instructions for Keyboard

  • Create or edit a Navigation block
  • Add a new Navigation Link block
  • Without entering any text or URL, press the Delete key
  • Verify that the empty link block is removed

Screenshots or screencast

screen-capture.webm

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: dhananjaykuber <[email protected]>
Co-authored-by: scruffian <[email protected]>

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

@shail-mehta shail-mehta added [Type] Enhancement A suggestion for improvement. [Block] Navigation Affects the Navigation Block labels Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Affects the Navigation Block [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Navigation: Can't delete default custom links.
2 participants