Skip to content

Navigation: Surface blocks and variations in Link UI search results - #78345

Closed
sarthaknagoshe2002 wants to merge 5 commits into
WordPress:trunkfrom
sarthaknagoshe2002:fix/issue-77074
Closed

sarthaknagoshe2002 wants to merge 5 commits into
WordPress:trunkfrom
sarthaknagoshe2002:fix/issue-77074

Conversation

@sarthaknagoshe2002

@sarthaknagoshe2002 sarthaknagoshe2002 commented May 15, 2026 •

Copy link
Copy Markdown
Contributor

What?

Closes #77074 & Closes #76803

This PR enables users to search for and insert allowed inner blocks (such as Site Logo, Search, or Home link) & block variations (like Category Link, Page Link, etc.) directly from the Navigation block's Link UI popover.

It also introduces contextual badges to the dropdown suggestions to help users distinguish between standard links, block variations, and standalone blocks.

Why?

Previously, adding inner blocks or specific entity variations to the Navigation block required a cumbersome, multi-step workflow separated from standard link addition. For example, adding a Home link required knowing to click "Add Block" -> "Browse All" -> Search "Home".
By integrating block and variation search directly into the Link UI's primary search bar, we:

  • Vastly improve the discoverability of specific entity links (Taxonomies, Categories, Home Link).
  • Reduce cognitive load by keeping the user in a single, unified search flow.
  • Streamline the overall menu-building experience in the Site Editor.

How?

Uses useSelect to gather all available block types and navigation link variations, and check their insertion permissions. It then filters this list in real-time based on the user's search input and whether the blocks/variation are actually allowed within the Navigation menu. Finally, it passes these matching blocks/variation down into the LinkUITools component, which loops through the results to display clickable insertion buttons for the user.

Introduces a getVariationBadgeLabel helper to dynamically generate right-aligned badges (e.g., "Category Link", "Block", "Taxonomy") for the search results, ensuring users know exactly what type of item they are inserting.

Testing Instructions

  1. Add a Navigation block to the editor and hover to reveal the + appender icon.
  2. Click the + to open the Link UI popover.
  3. Test Block Search: Type "Home" into the focused search input field. Verify the "Home Link" block appears with a "Block" badge, and clicking it successfully inserts the block.
  4. Test Variation Search: Open a new Link UI popover and type "Category". Verify the "Category Link" variation appears with the appropriate badge, and clicking it inserts a category link block.
  5. Test Context Isolation: Click on the newly inserted Category link to edit it. Type a generic term into the search bar. Verify that generic blocks (like Site Logo or Home) do not appear in the suggestions, as you are now restricted to searching for category entities.

Screenshots or screencast

Before After
image image

@github-actions github-actions Bot added the [Package] Block library /packages/block-library label May 15, 2026
@sarthaknagoshe2002 sarthaknagoshe2002 changed the title Feat: Add block suggestion in navigation appender Navigation: Add block search and insertion from Link UI May 15, 2026
@sarthaknagoshe2002
sarthaknagoshe2002 marked this pull request as ready for review May 15, 2026 14:07
@github-actions

Copy link
Copy Markdown

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: sarthaknagoshe2002 <sarthaknagoshe2002@git.wordpress.org>
Co-authored-by: jeryj <jeryj@git.wordpress.org>

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

@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. [Block] Navigation Link Affects the Navigation Link Block labels May 16, 2026
@sarthaknagoshe2002 sarthaknagoshe2002 changed the title Navigation: Add block search and insertion from Link UI Navigation: Surface blocks and variations in Link UI search results May 18, 2026

@jeryj jeryj left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Did a quick code review. The larger question is if this is the right design direction. I'm going to tag the original issue for discussion. I think the Components team also has some thoughts on the direction for this design.

I think adding allowed blocks to the LinkUI is the right move. They're hard to find otherwise. I'm not sure about the category/taxonomy items though. I think those might be better to surface when searching for the specific taxonomy item rather than including the alternate category block? For example, if I want to add a category, like "Favorites," I would rather type "Favorites" than type "Category" -> Select Category block -> Type "Favorites"

What do you think?

@@ -97,11 +124,13 @@ function UnforwardedLinkUI( props, ref ) {
const [ initialSearchValue, setInitialSearchValue ] = useState( '' );
// Tracks the live search input between renders without causing re-renders.
const searchInputValueRef = useRef( '' );
const [ searchInputValue, setSearchInputValue ] = useState( '' );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we need to add searchInputValue to state instead of relying on the ref?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We have to use state here because updating a Ref doesn't trigger a re-render. If we only update the ref, the matching items array will never recalculate and the dropdown UI won't visually update as the user types. The state trigers the render cycle needed for real time filtering. Happy to be corrected here & open to a more optimized approach.


// Filter insertable blocks by both capabilities AND the live search input in one pass.
// Empty query > no results (avoids flooding the UI before the user types).
const matchingItems = useMemo( () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this useMemo is trying to recalculate a lot of things on each keystroke. I'd think we should be able to grab what blocks are allowed in one pass on mount and then store that to filter just the matching blocks on query update.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What would be the preferred architectural approach here? Is there a different pattern you'd recommend here?

@jeryj

jeryj commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

I ended up going a different direction with how to address this. Added blocks to search results via a new transformSuggestions prop in LinkControl in #83652. Thank you for looking at this!

@jeryj jeryj closed this Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Navigation Link Affects the Navigation Link Block [Package] Block library /packages/block-library [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow adding a Home link in navigation item creation Navigation LinkUI: Include blocks and all entity types within search results

3 participants