Repository navigation
Fix: Hide the empty Meta Boxes pane when only side meta boxes are present and the pane is closed - #84306
Fix: Hide the empty Meta Boxes pane when only side meta boxes are present and the pane is closed#84306umeshnevase wants to merge 2 commits into
Conversation
…sent and the pane is closed
…sent The Meta Boxes pane below the editor only renders the `normal` and `advanced` locations, but its visibility check also counted `side`. With only side meta boxes (or none visible), an empty pane was still shown, open or closed. Only consider the `normal` and `advanced` locations when deciding whether to render the pane. Side meta boxes remain in the sidebar. Add unit tests for `isMetaBoxLocationVisible` and `MetaBoxesMain`, and an E2E spec with a side-only meta box test plugin.
🤖 PR meta 🤖👋 Welcome👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @umeshnevase! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. 🎉 PropsIf 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. Updated as activity occurs, without notifying anyone named here. Add the 🏷️ LabelsThis pull request needs exactly one label indicating its type, and has 0.
Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you. |
|
Hi @umeshnevase, thanks for your contribution. I don't think this is the ideal approach, so I'm going to close this issue. Please see #84173 (comment) for more details. |
What?
Closes #84173
Why?
The pane below the editor only holds the
normalandadvancedmeta box locations.sidemeta boxes are rendered in the sidebar. The check that decides whether to render the pane also countedside, so a post with only side meta boxes (or none visible) showed an empty "Meta Boxes" toggle bar, whether the pane was open or closed.How?
In
MetaBoxesMain(packages/edit-post/src/components/layout/index.jsx), thehasAnyVisiblecheck now looks only atisMetaBoxLocationVisible( 'normal' )andisMetaBoxLocationVisible( 'advanced' ). When neither is visible, the pane isn't rendered. Side meta boxes are unaffected.MetaBoxesMainis now a named export so it can be unit tested.Tests added:
isMetaBoxLocationVisibleselector cases inselectors.jsdom.test.js.layout/test/meta-boxes-main.jsdom.test.jscovers no meta boxes, side only, normal, advanced, and normal plus side.meta-boxes-pane.spec.js, with a new test pluginmeta-box-side-only.phpthat registers a side-only meta box.Testing Instructions
sidelocation only (orgutenberg-test-plugin-meta-box-side-onlyfrompackages/e2e-tests/plugins).normalmeta box (e.g.gutenberg-test-plugin-meta-box) and open a new post. The "Meta Boxes" bar appears and can be toggled open and closed.Automated:
Testing Instructions for Keyboard
normalmeta box active, Tab to the "Meta Boxes" button and press Enter or Space. The pane opens and closes, andaria-expandedupdates.sidemeta box active (or none), Tab through the editor. There is no "Meta Boxes" button or empty region to land on.Use of AI Tools
This PR was authored with assistance from Claude Code (Anthropic). Claude Code helped write the fix, the changelog entry and the unit, component and E2E tests. I reviewed all of the generated code and ran the unit tests locally.