-
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: Save theme location on button click #30340
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Maybe we can expose this as a function that takes a menu id and menu data as an alternative to returning
menuEntityData
. TheMENU_KIND
andMENU_POST_TYPE
aren't expected to change.I also discovered recently that there's a
useEntityProp
hook, that works similarly touseState
, so that wrapping that in some way might also be an option.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 guess to elaborate more, I'd consider
menuEntityData
as configuration that can be kept internal touseMenuEntity
.Instead of returning it the hook could return a partially applied version of
editEntityRecord
so that implementers don't have to worry about passing theMENU_KIND
andMENU_POST_TYPE
arguments.Just to also mention that there are other ways of achieving this too.
We might consider moving some of this to the edit-navigation store—an action in the navigation store can dispatch actions on another store. Selectors can also select from other stores. We could expose an
editMenuName
action and agetEditedMenuName
selector for convenience.Or there's the
useEntityProp
hook that I mentioned (https://github.com/WordPress/gutenberg/blob/trunk/packages/core-data/src/entity-provider.js#L74-L117), that provides an easier way to edit individual properties. We could also consider partially applied versions (e.guseMenuEntityProp
, or maybe evenuseMenuEntityName
/useMenuEntityLocation
) of this hook for convenience.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 have created a separate issue for this #30442
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 like the idea of
useMenuEntityProp
. Happy to create PR and update existing code.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.
Excellent @Mamaduka if you find the time to squeeze that it would be lovely 🙏
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.
Done #31132 ✅