-
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
Navigation Editor: Introduce useMenuEntityProp hook #31132
Conversation
Size Change: +2.94 kB (0%) Total Size: 1.31 MB
ℹ️ View Unchanged
|
I think this also fixes #30425. |
There's also #22623, which might influence how the selected menu id works. An option for solving that is to move the selected menu id to the store, and then use the persistence plugin (https://github.com/WordPress/gutenberg/tree/trunk/packages/data/src/plugins/persistence) to sync the value to local storage. |
32c0c39
to
7c295dd
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.
I tested this manually in the UI and didn't spot any regressions.
That said I'm not clear on
"Add new pages" should be saved when clicking the "Save" button.
From the code it looks like previously when you toggled Add new pages
in the Inspector sidebar the menu was automatically saved. Am I right in thinking this PR alters that behaviour so you now manually need to click Save
?
If so it feels like that might want to be a separate PR along with a rationale for why this is done. I may have the wrong end of this stick however 😄
With a little more info I would be happy to approve this one.
Sorry about that. I accidentally fixed #30425 when refactoring to use the new hook. The issue also has PR (#30446) that takes a different approach by moving state up the level and using the Happy to remove the "Add new pages" part and create separate PR for the mentioned issue. |
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.
No worries. Thanks for clarifying.
Happy to remove the "Add new pages" part and create separate PR for the mentioned issue.
Although it seems a bit tedious it might be easier to review in isolation 👍
I'll approve this PR because I know that the saving of the toggle only happened when I clicked the Save
button. I'll leave it to you as to whether you want to spin up a separate PR instead.
Hi, @getdave I reverted changes for "Add new pages" and will create a separated PR in a bit. Thanks again for the review. |
Sure thing. Let me know and I'll happily review. |
Description
Adds
useMenuEntityProp
as discussed in #30340 (comment). This is auseEntitytProp
wrapper hook that encapsulates menu constants and provides an easy way to access/edit individual menu properties.P.S. Maybe we should also introduce the
useSelectedMenuId
hook to get menuId from context. Most of the timeuseSelectedMenuData
hook is used for this.Fixes #30442.
How has this been tested?
Everything should work like before.
Types of changes
New feature
Checklist:
*.native.js
files for terms that need renaming or removal).