-
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
Fix Meta boxes saving when they’re not present #67254
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: -44 B (0%) Total Size: 1.83 MB
ℹ️ View Unchanged
|
Thanks for the PR! I can't review this PR now because I haven't yet been able to reproduce the issue, but the approach looks reasonable. This PR ensures that |
packages/edit-post/src/components/meta-boxes/use-meta-box-initialization.js
Outdated
Show resolved
Hide resolved
@stokesman thanks for looking into this. I quickly tested it and it does fix #67207 Seems a better approach than #67228 To my understanding: While the presentation in the UI of the meta boxes will be still controlled by hasAnyVisible >
instead, the functionality and thus the POST request will be controlled by this new check, which only checks whether there is a metabox in a location, regardless of whether it's active in the preferences. Is that correct? |
It will not only when none of the locations have any meta boxes. If the "side" location has a meta box and the "normal" or "advanced" do not then
Correct 🎯 |
Flaky tests detected in db46c07. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12015860595
|
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've tested this PR again and everything works as expected, so I think it can be backported to WP 6.7.2.
packages/edit-post/src/components/meta-boxes/use-meta-box-initialization.js
Outdated
Show resolved
Hide resolved
@t-hamano, @stokesman I tried to do a cherry-pick to the
I don't have the context to decide what should be in 6.7 branch vs trunk right now. Can you please take a look? Otherwise it will take some time to understand everything 😅 |
It looks like the only thing that needs kept from this branch in those conflicted sections is: useMetaBoxInitialization( hasActiveMetaboxes ); I’ve made #67503 as such. I’ve yet to manually test it but I’ll do so now. UPDATE: That PR works well but while testing I realized this PR had introduced a separate regression. Now meta boxes don’t hide/show as intended. I have #67504 open to fix trunk. |
isEditorReady: __unstableIsEditorReady(), | ||
}; | ||
}, | ||
[ location ] |
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 dependency should not have been removed 🤦♂️.
[ location ] | ||
const metaBoxes = useSelect( | ||
( select ) => | ||
select( editPostStore ).getMetaBoxesPerLocation[ location ] |
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 be a function call getMetaBoxesPerLocation( location )
. Bummer this was missed as it seems to break hiding/showing of the meta boxes.
* Initialize meta boxes whether or not they’re visible * Add hook for initialization of meta boxes * Minimize hook for meta boxes initialization * Name the export Co-authored-by: stokesman <[email protected]> Co-authored-by: afercia <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: Mamaduka <[email protected]> Co-authored-by: enricobattocchi <[email protected]>
* Initialize meta boxes whether or not they’re visible * Add hook for initialization of meta boxes * Minimize hook for meta boxes initialization * Name the export Co-authored-by: stokesman <[email protected]> Co-authored-by: afercia <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: Mamaduka <[email protected]> Co-authored-by: enricobattocchi <[email protected]>
What?
Ensures meta boxes are saved even if none of their areas are present in the Post editor’s UI.
Fixes #67207. Alternative to #67228 (or possibly a follow up to it).
Why?
Besides fixing a bug, this makes the meta box initialization more explicit/visible. It’s also a small optimization by invoking an effect in fewer places and executing less code when meta boxes aren’t present.
It seems more sensible this way because the initialization of all meta boxes is not really a responsibility of a component that represents only a single area of meta boxes.
How?
MetaBoxes
componentLayout
componentTesting Instructions
open the Yoast SEO sidebar and change a setting, e.g. the focus keyphrase