-
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 Editor: Navigation links added to menu only preserve url and label attributes #29793
Comments
@gwwar This is related. I found the same issue. Perhaps we can try and persist the relevant fields from the block to those on the Nav Menu object. https://core.trac.wordpress.org/browser/tags/5.7.1/src/wp-includes/nav-menu.php#L786 For example, |
Just noticed that there is just a single |
@gwwar I have a PR up which I believe will address this but I'd be interested in your advice. Essentially we have two places in code where we are creating
2: In the Navigation Block itself: gutenberg/packages/block-library/src/navigation/placeholder.js Lines 40 to 83 in 1420935
There is some lack of consistency between these approaches and we are also missing a number of opportunities to parse all the available data from the menu objects in the database when we convert to blocks. That is what you noticed in your Issue report. My PR addresses some of this. But I wonder whether you think a good follow up might be to create a single source of truth for the act of parsing database menu objects into blocks? The current code is not DRY and has proven to be a maintenance issue - therefore I believe it is a good candidate for a refactor. |
I'm not sure if this is intentional or not, but we only preserve the label and url attributes of a navigation link, when we save this in the navigation editor.
This means saving in the navigation editor is a bit lossy. For example, draft links will render on the frontend because id and type is not available to check. This may also be an issue for any future functionality that's added to navigation links.
Post links and other types of links added in customer or nav-menu also lose information when saved in the navigation editor and get turned into custom links.
Enabling the Navigation Editor
To enable the Navigation Editor:
Post links from customizer/nav menu turning into custom links
menu-3.mp4
Expected: Menu contains a single post link
Actual: Menu contains a custom link
Losing Properties When Loading a Menu into the Navigation Block
menu.mp4
As a quick example here's a navigation block loaded from a menu:
And here's one built in the post editor:
If I spotted this correctly serialization/hydration occurs in:
gutenberg/packages/edit-navigation/src/store/utils.js
Lines 132 to 147 in b7f3416
gutenberg/packages/edit-navigation/src/store/resolvers.js
Lines 146 to 155 in b7f3416
We might also need server changes if menu items cannot save arbitrary properties.
The text was updated successfully, but these errors were encountered: