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

Navigation Block: Block patterns with overlayMenu set to always do not appear correctly by default #36670

Closed
kjellr opened this issue Nov 19, 2021 · 3 comments · Fixed by #37358
Assignees
Labels
[Block] Navigation Affects the Navigation Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@kjellr
Copy link
Contributor

kjellr commented Nov 19, 2021

When a pattern has the hamburger menu set to display "Always" via "overlayMenu":"always", that setting is not reflected in the block preview, or in the editor until the user clicks on the block.

You can reproduce this by pasting some sample markup into the code editor:

<!-- wp:navigation {"itemsJustification":"right","overlayMenu":"always"} -->
<!-- wp:page-list {"isNavigationChild":true,"showSubmenuIcon":true,"openSubmenusOnClick":false} /-->
<!-- /wp:navigation -->

When you exit the code editor, you'll see that this does not show the overlay menu button. But when you click on the block, it appears:

nav

The overlay menu button appears as expected on the front-end regardless of whether you've clicked into it or not.

Gutenberg version: Version 12.0.0-rc.1 (trunk)

cc @talldan + @tellthemachines in case you two know what's happening here. I suspect is has to do with other recent changes to the block.

@kjellr kjellr added [Type] Bug An existing feature does not function as intended [Block] Navigation Affects the Navigation Block labels Nov 19, 2021
@kjellr
Copy link
Contributor Author

kjellr commented Nov 22, 2021

I'm going to add to must-haves for visibility. I think that's reasonable since this is used in multiple Twenty Twenty-Two patterns. Thanks! 🙌

@ntsekouras
Copy link
Contributor

ntsekouras commented Nov 30, 2021

With this PR Page List doesn't have any attributes, so the provided markup seems to had been created before these changes. Also it seems to be related with the change of Navigation to custom post type.

@talldan
Copy link
Contributor

talldan commented Dec 1, 2021

Sorry I missed the ping.

I think I know the issue here. When defining inner blocks in that way, the block doesn't show the inner blocks in the normal way, instead it renders a different UnsavedInnerBlocks component, and that doesn't have the overlay menu built into it:

if ( hasUnsavedBlocks ) {
return (
<UnsavedInnerBlocks
blockProps={ blockProps }
blocks={ innerBlocks }
clientId={ clientId }
navigationMenus={ navigationMenus }
hasSelection={ isSelected || isInnerBlockSelected }
hasSavedUnsavedInnerBlocks={ hasSavedUnsavedInnerBlocks }
onSave={ ( post ) => {
setHasSavedUnsavedInnerBlocks( true );
// Switch to using the wp_navigation entity.
setRef( post.id );
} }
/>
);
}

As soon as the block is clicked on its migrated to a saved menu, at which point it starts rendering normally.

In trunk currently, the behavior is different again to what's shown in the PR description. When the block is selected the inner blocks are now wiped out.

So it looks like there's now a double bug.

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 [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
3 participants