-
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: Allow menu renaming #29012
Conversation
Size Change: +521 B (0%) Total Size: 1.4 MB
ℹ️ View Unchanged
|
…tton, when clicked name editor is focused
…o preserve the same order of items in navbar
packages/edit-navigation/src/hooks/use-navigation-editor-menu.js
Outdated
Show resolved
Hide resolved
saveNavigationPost( navigationPost ); | ||
saveMenuName(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't anticipate this, but both these lines result in the menu being saved. saveNavigationPost
saves the menu via the customizer API (because the REST API doesn't quite work yet for saving menu items).
I'd be worried about race conditions here.
This is some technical debt, so not really something caused by your PR.
I don't have a solution available right now, will have to have a think about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the edge case when the race condition could really happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm worried that one request might overwrite the other, since both API requests can modify the same database record.
I think the easiest solution right now would be to make sure the requests happen sequentially. This could be done by moving the saveEditedEntityRecord
dispatch to be inside the saveNavigationPost
action. Should be able to dispatch it with code like this, where the yield
will wait for the request to complete before triggering the second request (the call to batchSave
):
yield dispatch(
'core',
'saveEditedEntityRecord',
'root',
'menu',
menuId
);
This makes sense actually, as it means the on-screen notices that are implemented in saveNavigationPost
can be made so that the visible notices associated with saving are displayed at the right time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some further background. The way saving menus currently works is a temporary thing. Currently the batchSave
function has been patched to use an endpoint that is currently used by the Customize > Menus screen. But that isn't part of the REST API, and not something we want to support long into the future for the navigation editor.
Ideally the whole system would use the WordPress REST APIs and the core-data package's entities. There are two things that need to happen:
- Add a way to reorder menu items using the REST API (REST API: Introduce reorder menu endpoint #25093)
- Update the navigation editor to use the core-data package's newly introduced batch save API (from Core Data: Add __experimentalBatch() #28210) for saving menus and menu items.
@shaunandrews Can those be addressed separately? The help text is from the TextControl components styling, so is something that should be addressed in a separate change. I'd be pretty keen to get this PR shipped as soon as @grzim wraps up the code review changes, as this is an important missing feature for the screen. I realise the submit button is also missing because of my advice in reviewing the previous PR before your designs were posted. Maybe I can make up for that by addressing that in a follow-up PR myself. |
Fine by me. Lets keep improving. |
I tried rebasing this. Fixing the conflict is easy ( |
…s/gutenberg into add/navigation-menu-name-editor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for all your patience in the code review process.
9b5bf3b
to
2f53f2f
Compare
Should we do the same treatment for Reusable blocks? |
Description
Advances #28856
Advances #28864
This PR includes a menu name editor placed in the navbar.
The menu name is displayed in the toolbar - upon clicking on it, the menu editor is focused.
According to design #28864 (comment)
How has this been tested?
Tested manually
Screenshots
Types of changes
New feature
Checklist: