-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Allow renaming, duplication and deleting of Navigation menus from Browse Mode Sidebar #50880
Conversation
packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/index.js
Outdated
Show resolved
Hide resolved
Size Change: +806 B (0%) Total Size: 1.39 MB
ℹ️ View Unchanged
|
5c18e6a
to
5296e28
Compare
Flaky tests detected in e49e2ec. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5241888040
|
bc5fc4f
to
99f65f2
Compare
I have a few questions on behavior:
|
packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/index.js
Outdated
Show resolved
Hide resolved
packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/index.js
Outdated
Show resolved
Hide resolved
a7feb63
to
b71de84
Compare
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.
Thank you for this PR. It is looking really good.
Let's do some code quality work upfront to make the files easier to reason about and maintain going forward.
We also need to address the error handling which includes:
- displaying appropriate notices to the user
- taking the appropriate action in the UI (if required)
packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/index.js
Outdated
Show resolved
Hide resolved
packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/index.js
Outdated
Show resolved
Hide resolved
packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/index.js
Outdated
Show resolved
Hide resolved
packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/index.js
Outdated
Show resolved
Hide resolved
packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/index.js
Outdated
Show resolved
Hide resolved
packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/index.js
Outdated
Show resolved
Hide resolved
packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/index.js
Outdated
Show resolved
Hide resolved
packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/index.js
Outdated
Show resolved
Hide resolved
packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/index.js
Outdated
Show resolved
Hide resolved
packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/index.js
Outdated
Show resolved
Hide resolved
packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/index.js
Outdated
Show resolved
Hide resolved
b71de84
to
223c67b
Compare
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.
Update: this is now fixed.
Screen.Capture.on.2023-06-09.at.10-28-54.mp4
I found a bug here. Because we're using editEntityRecord it's making changes to the record in state even when we dismiss the modal. That's not what we want. We can keep the rename state local to the modal.
This comment was marked as resolved.
This comment was marked as resolved.
@@ -74,6 +116,14 @@ export default function SidebarNavigationScreenNavigationMenu() { | |||
|
|||
return ( | |||
<SidebarNavigationScreenWrapper | |||
actions={ | |||
<ScreenNavigationMoreMenu | |||
menuTitle={ decodeEntities( menuTitle ) } |
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.
menuTitle={ decodeEntities( menuTitle ) } | |
menuTitle={ menuTitle } |
Let's pass the raw value here and allow the ScreenNavigationMoreMenu
to handle output.
import { useState } from '@wordpress/element'; | ||
|
||
export default function RenameModal( { menuTitle, onClose, onSave } ) { | ||
const [ editedMenuTitle, setEditedMenuTitle ] = useState( menuTitle ); |
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.
We'll need to decodeEntities
here and also ensure the button disabled check accounts for this.
packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/rename-modal.js
Outdated
Show resolved
Hide resolved
@jasmussen I have fixed the following from your review: Input focus clippingMore menu popover stylingI also added a confirmatory step to the Delete action |
<VStack spacing="3"> | ||
<p> | ||
{ __( | ||
'Are you sure you wish to delete this Navigation menu?' |
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.
@jasmussen Are you happy with this wording or would you prefer want
over wish
?
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.
Small preference for want, but not strong at all.
const originalRecord = getEditedEntityRecord( | ||
'postType', | ||
'wp_navigation', | ||
postId | ||
); | ||
|
||
// Apply the edits. | ||
editEntityRecord( 'postType', postType, postId, edits ); | ||
|
||
// Attempt to persist. | ||
try { | ||
await saveEditedEntityRecord( 'postType', postType, postId, { | ||
throwOnError: true, | ||
} ); |
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.
This whole edit then save flow seems really clunky. I'm not sure if there is a better way but if there is I'm keen to learn. Currently we're having to save a copy of the record prior to editing in order that we can revert afterwards.
Note that using saveEntityRecord
directly doesn't work as expected. You have to use editEntityRecord
in conjunction with saveEditedEntityRecord
(note the "Edited") to make it work.
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.
yeah, this was confusing to me too!
packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/index.js
Outdated
Show resolved
Hide resolved
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.
This is looking great, just a couple of things left to do!
For the clipped input, I'm fine with moving forward to not bog down things in details, but a few quick notes just to capture them:
Thanks for the followup Dave! |
Thank you so much for picking this one up. It's looking really good. Thank you for commenting the code so effectively as always, it goes a long way. I'm going to defer to someone else for the ✅ but this is looking great so far. |
packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/delete-modal.js
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
.sidebar-navigation__rename-modal-form { |
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.
Should we remove this and do the fix in the modal component?
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.
Let's bring this in and iterate.
…wse Mode Sidebar (WordPress#50880) * added more menu to navigation with delete menu option * modal for the rename function * prop refactoring, title on rename popup * very ugly renaming of the menu * duplicate function * added snackbar notices to each action * navigate to correct places on delete and duplicate. Added Copy after title on duplication * i18n Co-authored-by: Ben Dwyer <[email protected]> * Another i18n Co-authored-by: Ben Dwyer <[email protected]> * Apply suggestions from code review Co-authored-by: Ben Dwyer <[email protected]> * Use self documenting var name * Use consistent confirmatory action wording * Refactor MoreMenu to component * Extract Modal to seperate component * Refactor change function * Use local state and only edit record on “save” confirmation * Localise state closer to where it’s needed * Disable “Save” button until menu title is modified * Remove file import introduced during rebase * Handle Save errors * Error handling for Delete action * Force all actions to throw on error * Add error handling for Duplicate. Also pass error message and not error object. * Improve loading feedback when saving or deleting * Make prop naming consistent * i18n of modal title * Add confirmatory step prior to delete action * Fix rename input focus border clipping * Use default variant to get correct styles * Make `Copy` translatable * Updating confirmatory wording --------- Co-authored-by: Dave Smith <[email protected]> Co-authored-by: Ben Dwyer <[email protected]>
What?
Following the UX suggested in #50583 this PR implements a new ellipsis menu in browse mode that allows us to rename, duplicate and delete menus
Closes #50583
Why?
Some of these actions were not available to the user yet.
This is part of the effort to improve Navigation on browse mode.This PR has subsequently undergone several revisions and so it should be in a good state.
How?
Follow Ups
The following items would be good for a followup.
Navigation
at the top of the panel when something is changing/navigation
and then reverting on error.Testing Instructions
Screenshots or screencast
Screen.Capture.on.2023-06-09.at.14-20-17.mp4
Co-authored-by: Dave Smith [email protected]