-
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: Move selected menu ID to the store #31320
Conversation
* Removes useSelectedMenuData hook * Removes MenuIdContext
Size Change: -994 B (0%) Total Size: 1.31 MB
ℹ️ View Unchanged
|
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 tested this and it did indeed select the last menu I had selected displayed when reloading. I also saw the value in localStorage
.
This also works if you delete all menus - there are no errors.
I don't know much about the persistence plugin but it seemed to work well.
Update: looks like you have a failing e2e test.
@@ -73,7 +75,7 @@ export default function useNavigationEditor() { | |||
force: true, | |||
} ); | |||
if ( didDeleteMenu ) { | |||
setSelectedMenuId( null ); | |||
setSelectedMenuId( 0 ); |
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.
Just checking...is it safe to set this to 0
? What if there are no menus left?
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.
If there are no menus left, the screen will display create menu placeholder. I'm using 0
here so we can have a single type for selectedMenuId. But having null
as in no menu was selected also makes sense to me.
Description
Attempt to move currently selected menu ID to the store. Value is synced to localStorage as suggested here #31132 (comment).
PR introduces new actions/selector for working with selected menu ID.
Other changes
useSelectedMenuId
hook for convenience.useSelectedMenuData
hook andMenuIdContext
.Fixes #22623.
How has this been tested?
Testing the store changes:
npm run test-unit -- packages/edit-navigation/src/store/test
Types of changes
New feature (non-breaking change which adds functionality)
Checklist:
*.native.js
files for terms that need renaming or removal).