-
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: Enable undo after creating a new menu #47683
Conversation
Size Change: -86 B (0%) Total Size: 1.31 MB
ℹ️ View Unchanged
|
Flaky tests detected in 74c77d21f3f38ca3f7f6519261061b0103b8528b. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4104222269
|
packages/block-library/src/navigation/edit/use-create-navigation-menu.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.
It's great this is being addressed. It's been a problem for too long. Thank you.
This seemed to work well for the basic use case.
I'm not 100% but I think I found a bug:
- Nav block with existing menu set
- Create new menu
- Create a menu item in that menu
- Click undo until you get back to your original menu (the one you had at the start)
- Now click redo - notice how you cannot get back to the new menu with the newly created item 😞
Screen.Capture.on.2023-02-03.at.11-16-05.mp4
@getdave do you think that is that a bug caused by this PR? Because testing in trunk is weird since in trunk you can't get back at all :) |
I honestly have no idea. I doubt it's directly caused by it although it obviously could be. I'd vote for merging this one and following up to see if we can fix the issue I encountered. |
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.
Broadly this does what it says on the tin 👍
As mentioned we should raise a follow up Issue/PR for the bug I noticed.
27c6551
to
74c77d2
Compare
Hi @fluiddot :) me again! This PR removes and effect from the navigation block and somehow it causes a React test to fail:
Can you please 🙏🏻 point me to something I can start to investigate? |
…dds it to the create menu hook
Co-authored-by: Daniel Richards <[email protected]>
74c77d2
to
7bdc00e
Compare
Thanks @draganescu for the call out 🙇. I checked the changes introduced in this PR and in this case, the failure on the mobile E2E tests seems unrelated and most likely caused due to flakiness in those tests. Let's try to restart them and check again if they succeed 🤞. UPDATE: As we speak, we are currently working on making the mobile E2E tests more stable. |
@fluiddot awesome! I will then merge this with this test failing. I want to make sure it makes it in 6.1 and it already failed to land in the beta. Thank you for the help! Geronimo! |
* removes the publish status effect from navigation edit componet and adds it to the create menu hook * Only edit in memory for Drafts Co-authored-by: Daniel Richards <[email protected]> --------- Co-authored-by: Daniel Richards <[email protected]>
Cherry-picked this PR to the wp/6.2 branch. |
What?
Advances #46476
When creating a new menu, undo does not do anything although it is available. This PR fixes that allowing undo to go back to the previously selected menu.
Why?
Because creating a new menu should be undoable somehow, particularly since the names of the menus are quite similar by default so it's confusing to know which one was selected before. Plus the undo button showed it should work.
How?
The Navigation edit component had an effect which set the newly created navigation to a publish status. That served two purposes:
This PR removes this effect which somehow broke the undo. It moves the in memory edit right after the menu is created, in the hook which provides the menu creation procedure.
Undoing a menu creation does not delete the newly created menu, it only restores the previously selected menu.
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
working-undo-create.mp4