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

Create a legacy menu block #36576

Open
spacedmonkey opened this issue Nov 17, 2021 · 11 comments
Open

Create a legacy menu block #36576

spacedmonkey opened this issue Nov 17, 2021 · 11 comments
Assignees
Labels
[Block] Navigation Link Affects the Navigation Link Block [Block] Navigation Affects the Navigation Block New Block Suggestion for a new block [Type] Enhancement A suggestion for improvement.

Comments

@spacedmonkey
Copy link
Member

What problem does this address?

The current navigation block is not backwards compatible with existing menu / menu item code. This means that current implementations that filter / change menus, will not work.

What is your proposed solution?

Add a new legacy navigation block, that allows user to select menu a dropdown and have the menu be rendered server side with wp_nav_menu that would maintain backwards compatibility.

@spacedmonkey spacedmonkey added New Block Suggestion for a new block [Block] Navigation Affects the Navigation Block [Block] Navigation Link Affects the Navigation Link Block labels Nov 17, 2021
@spacedmonkey spacedmonkey self-assigned this Nov 17, 2021
@spacedmonkey spacedmonkey added this to Inbox in Navigation editor via automation Nov 17, 2021
@getdave
Copy link
Contributor

getdave commented Nov 18, 2021

Thanks for raising this @spacedmonkey.

So this would effectively be an opt out similar to Classic Widgets? It would allow the user to use a block in FSE that would render their menu as it was in a classic Theme using wp_nav_menu().

Questions:

  • Do you see this living in Gutenberg Core or as a Plugin?
  • What danger is there that by offering this, we lose (water down) the opportunity to push the Navigation block forward in response to feedback from users?
  • I also sense that there is a push to avoid using ServerSideRender as it doesn't provide a great UX in the Editor. Are there any alternatives we could consider?
  • What time frame should we consider for this?
  • We have considered a legacy menu block previously. What has caused you to push for this again? I'm curious as to whether there is there a specific use-case or interaction that has prompted this?

Much appreciated.

@manooweb
Copy link
Contributor

manooweb commented Nov 18, 2021

Hi @getdave,

I can answer to the latest question and maybe partially to the third one and as you saw in the conversation on slack.

In fact, in Polylang plugin we have a specific language switcher menu item we can use in the classic menu. It is specific because it is not a menu item as the other ones because it doesn't generate a simple link but several links (one per language).

The current migration feature when we use the new navigation block produce for all the menu items a navigation-link block.
For our specific menu-item, it's wrong: it should be converted to our navigation-language-switcher block.

We were looking for a solution when I asked a question on slack to know where the current conversion is done.
Surely here, I suppose 🤔https://github.com/WordPress/gutenberg/blob/v11.9.1/packages/block-library/src/navigation/menu-items-to-blocks.js

I push here the video I previously pushed on slack to better illustrate what I explain.
https://user-images.githubusercontent.com/1003778/142417108-4d3961f0-6ab9-4b1c-b32b-c4085a362e77.mp4

I would see an alternative: open the navigation block conversion to make it extensible and make possible to decide how to convert some menu-item. It's just an idea and what we were looking for at the beginning.

However, it exists a disavandatage for our plugin. Indeed our navigation-language-switcher block is only implemented in our Pro version and then can't be used in our free version.
Use of a "legacy menu" should be acceptable in this case because there is no need to convert the menu and all works as it does today: server side.

@getdave
Copy link
Contributor

getdave commented Nov 18, 2021

@manooweb Thank you for your replies. It's great to have this use case requirement clearly illustrated.

Let's keep this Issue specific to your later point regarding the (possible) need for a Legacy Menu block.

I created a separate Issue in order that we can discuss the requirement for hooking into the conversion from classic Menu to Navigation block.

Much appreciated 🙇

@spacedmonkey
Copy link
Member Author

I created a prototype of a classic menu block. https://github.com/spacedmonkey/classic-menu-block

After WordPress I will submit this plugin to the WP plugin repo. It will be a nice workaround for some of your issues @manooweb

@manooweb
Copy link
Contributor

manooweb commented Dec 6, 2021

Wow! Thanks @spacedmonkey, I'm stuck at the moment with the other solution proposed in #36950
I'm going to take a look at this one 👍

@manooweb
Copy link
Contributor

manooweb commented Dec 7, 2021

@spacedmonkey I took a look at your plugin.
The issue at the beginning isn't a frontend rendering problem but a WYSIWYG rendering problem of the navigation block.

For the moment, here is what I get with your plugin
The classic menu block
image

renders a navigation block which doesn't contain the language switcher but a navigation link Languages instead. The issue is there.
image

Otherwise in frontend it works correctly as the classic menu in the header
image

Tested:

@manooweb
Copy link
Contributor

manooweb commented Dec 7, 2021

🤔Sorry after investigation, it seems that it's Polylang that doesn't manage the language switcher menu item in a admin/REST context. I'm going to test by moving a line of code a the right place and I let you know

@manooweb
Copy link
Contributor

manooweb commented Dec 7, 2021

It was really that 👍 We need to copy a class instantiation in the REST Polylang context and it works fine now.
image

@spacedmonkey
Copy link
Member Author

@manooweb I released the plugin on the repo. Here is the blog post about it.

@carolinan
Copy link
Contributor

Is this something we are still considering implementing as a separate block?

@manooweb
Copy link
Contributor

manooweb commented Feb 7, 2023

Is this something we are still considering implementing as a separate block?

Hi @carolinan.

For us - Polylang plugins - we still need this classic menu block.
Indeed we've been implemented a language switcher block however only in our Pro version.

So, for all the users who use our plugin provided on WordPress.org it is the only solution to be able to use the language switcher in a menu with a site editor compatible theme.

Regards.

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 [Block] Navigation Affects the Navigation Block New Block Suggestion for a new block [Type] Enhancement A suggestion for improvement.
Projects
No open projects
Development

No branches or pull requests

5 participants