-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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: Change how we create classic menus #42850
Comments
@scruffian I have an idea. You could create the menu as a draft, but immediately trigger Personally I feel like that's a nicer approach compared to #43190, part of something being a draft is that it's not publicly visible so it's sort of using the right semantics. There may be a couple of other things to tackle. There are a couple of places that reference the 'publish' status status for the nav block that might cause drafts not to work as expected:
|
This solution seems to be working but, also, creates duplicated navigation menus that could last forever on the DB (I cannot find an easy way to get to navigation menus as a user). I will keep you updated! |
I don't fully follow this. So you're saying as a user you've clicked on one of the classic menus. The code has run the conversion to a block menu and then updated the block. What's the problem? How does this manifest for the user? |
I guess the problem here is that change (conversion from page list to block elements menu) happens automatically (which is cool) but also is autosaved. |
The behaviour for creating a new menu and importing a classic menu are inconsistent. If I create a new menu, but don't save my changes, the front of the site is unchanged. If I import a classic menu then the frontend of the site is changed immediately without me saving anything. |
I tried @talldan 's idea in #43580, it works, but it may cause duplicated draft menus. |
This is a really clear explanation of the problem. Thank you. Now my question is what makes that behaviour inconsistent? What specific process occurs that makes one different from the other? |
The specific difference between those two processes is that creating a new menu starts with one empty (so then the frontend shows the fallback (page list) and the editor shows an empty navigation menu. And importing a classic menu creates one with content. In this last case, the frontend has a published menu with content (so it shows) and the editor also shows the menu with its content. Possible solutions could be:
In both cases, we need to force the site editor on load to become dirty to allow the user to publish draft menus, or think about a better flow for this approach. |
What problem does this address?
When you create a new navigation menu from a classic menu then a new wp_navigation CPT is created, which is already populated with the content of the classic navigation. The upshot of this is that as soon as the classic navigation is created the fallback behaviour of the block is changed and the classic menu is used instead of page list (as described in #42799)
What is your proposed solution?
There are two potential solutions:
1. Create the classic navigation as a "draft" CPT.
I tried this approach, simply changing the status of the record from "published" to "draft" when the CPT is created (in
use-create-navigation-menu.js
). This does change the new CPTs to bedraft
, but the post doesn't get marked as dirty in the entity saving flow. We would need to update the enitity saving flow to understand draft posts. I don't know how complex this would be.2. Create the classic menu empty and then replace inner blocks with the classic navigation items
Alternatively we could create the new "classic" wp_navigation CPT empty (which is what happens when you create a new navigation menu normally), and then populate the inner blocks with the navigation items that were returned from the API. This should mark the block as "dirty" for the entity saving flow, so it feels like it should be a simpler approach. I made a start here: #43190
The text was updated successfully, but these errors were encountered: