Fix: Refless Navigation Block does not show block appender - #77688
Open
hbhalodia wants to merge 4 commits into
Open
Fix: Refless Navigation Block does not show block appender#77688hbhalodia wants to merge 4 commits into
hbhalodia wants to merge 4 commits into
Conversation
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Contributor
|
This seems to address your issue @jeryj no? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Closes #75215
Why?
How?
<NavigationInnerBlockscomponent to add the appender.Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
Screen.Recording.2026-04-27.at.5.02.44.PM.mov
Use of AI Tools
AI summary and root cause
Issue: Refless Navigation Block Does Not Show Block Appender
Summary
When a navigation block has no
refattribute (i.e., its inner blocks are defined directly in the post content rather than referencing awp_navigationentity), clicking a navigation link does not show the block appender (the "+" button for adding new items). In contrast, a ref-based navigation block correctly shows the appender.Root Cause (Two Interrelated Issues)
The bug stems from a behavioral mismatch between two separate components that render the Navigation block's inner blocks:
ref)NavigationInnerBlocksuseEntityBlockEditor)InnerBlocks.ButtonBlockAppendershown when selected, child selected, or any descendant selectedref, unsaved)UnsavedInnerBlocksinnerBlocks)undefined) shown only whenhasSelectionis truthyIssue 1: No Block Overlay on Refless Navigation
In the block editor store, the function
__unstableHasActiveBlockOverlayActivedetermines whether a block gets a content overlay (intercepting clicks so the first click selects the parent block). The critical condition is:For ref-based navigation, inner blocks are controlled (managed by
EntityProvider+useEntityBlockEditor), soareInnerBlocksControlledreturnstrue→ overlay is active → first click selects the parent navigation block.For refless navigation, inner blocks are uncontrolled (stored directly in the block tree), so
areInnerBlocksControlledreturnsfalse→ no overlay → first click goes directly to the child navigation link.Issue 2: Incorrect
renderAppenderinUnsavedInnerBlocksIn
unsaved-inner-blocks.js:When
hasSelectionistrue(which equalsisSelected || isInnerBlockSelected),renderAppenderis set toundefined. The valueundefinedmeans "use the default appender", which only renders when the block itself is selected — not when an inner block is selected.Compare this with
inner-blocks.js(used for ref-based navigation):This explicitly uses
InnerBlocks.ButtonBlockAppender, which renders whenever the condition is met — including when any descendant is selected.Combined Effect
hasSelection=true(becauseisInnerBlockSelectedis true)renderAppender=undefined(default appender)The Fix
Update
UnsavedInnerBlocksto useInnerBlocks.ButtonBlockAppenderexplicitly, matching the behavior ofNavigationInnerBlocks. The component also needs to compute more granular selection state.File:
packages/block-library/src/navigation/edit/unsaved-inner-blocks.jsAnd in the parent
index.js, passclientIdtoUnsavedInnerBlocks:<UnsavedInnerBlocks createNavigationMenu={createNavigationMenu} blocks={uncontrolledInnerBlocks} hasSelection={isSelected || isInnerBlockSelected} + clientId={clientId} />Why This Fixes It
InnerBlocks.ButtonBlockAppenderexplicitly renders the "+" button regardless of which block is selected, as long as the condition evaluates totruehasSelectedDescendantcaptures the case where any nested block is selected (not just immediate children)NavigationInnerBlocks, making the behavior consistent between ref-based and refless navigation blocksAlternative Simpler Fix
If you want a minimal change without adding new
useSelecthooks:This alone would fix the appender visibility because
hasSelectionalready includesisInnerBlockSelected. The only difference from the full fix is that it doesn't have the fine-grained "don't show appender if selected child has its own children" logic, but for navigation blocks this is unlikely to matter.I would raise the PR with a fix and will discuss the approaches there. At a first glance it has mimiced what is being used by the ref navigation. Ideally this should be the acceptable.