Repository navigation
Add opt-in editor sidebar for field groups (beta) - #548
faisalahammad wants to merge 2 commits into
Conversation
Wire the existing editor_sidebar beta feature into the registry and register eligible field group meta boxes with side context when the beta is enabled and the post type uses the block editor. Rewrite the saved meta box order so it cannot pull the boxes back out of the sidebar, and report the sidebar position from the check_screen AJAX response for dynamically added groups. Classic editor post types and the beta-off state are unchanged. See WordPress#154
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
The block editor on WP trunk renamed the View menu item from "Preview in new tab" to "Preview (opens in a new tab)". The pinned e2e test helper still matches the old label exactly, so every test that opens a preview timed out. The fixture now clicks the button itself and matches the item with a regex that accepts both labels. Fixes the WP trunk E2E timeouts waiting for the preview page. Refs WordPress#548
|
Thanks for the contribution and the effort here! 🙏 A heads-up on how this repo works: a large part of SCF's codebase (field types, Flexible Content, Blocks v3, local fields, forms, value formatting, and most of includes/ and assets/src/js/) is regularly synced from an upstream codebase. Any change we make there, whether a bug fix or a new feature, gets overwritten or causes hard merge conflicts on the next sync. That includes features behind a beta flag. Fixes for those areas arrive through the sync itself, so we can't accept PRs that touch that code, even good ones. |
Move field groups into the block editor sidebar behind an opt-in beta feature. When the beta is enabled and the post type uses the block editor, field groups are registered with
sidemeta box context so Gutenberg renders them in the editor sidebar natively. Field rendering, saving and validation stay on the existing paths.See #154
What changed
Beta feature is now reachable.
includes/admin/beta-features.phpincluded a class file that does not exist and had an empty registry, so theeditor_sidebarfeature could never appear. It now loadsclass-scf-beta-feature-editor-sidebar.phpand registers it. The feature shows up as "Move Elements to Editor Sidebar" under Field Groups > Beta Features.Sidebar placement.
includes/api/api-helpers.phpadds threescf_helpers.scf_field_groups_use_editor_sidebar()returns true only when the beta is on anduse_block_editor_for_post_type()accepts the post type.includes/forms/form-post.phpuses it to switch the meta box context of groups positionednormal,advancedoracf_after_titletoside, keeping the existingacf/input/meta_box_priorityfilter andcorepriority.Saved order cannot undo the move. WordPress re-registers meta boxes from the saved
meta-box-order_{screen}user option, which pulls them back out of the sidebar.form-post.phpandincludes/ajax/class-acf-ajax-check-screen.phprewrite that option for the affected box IDs, same approach as the existingacf_after_titlehandling inACF_Form_Gutenberg. The check_screen response also reports the sidebar position for groups added dynamically.E2E fixture for the renamed preview menu item.
tests/e2e/fixtures.jsis a test only change, included to get the WP trunk E2E matrix green. The editor View menu item was renamed to "Preview (opens in a new tab)" in Gutenberg, and the pinned@wordpress/e2e-test-utils-playwright@1.32.0helper still matches the old label exactly, so all 39 tests that open a preview timed out on trunk. The fixture now clicks the button itself and matches the menu item with a regex that accepts both labels. Nothing in this PR depends on it. See the CI Fix Summary comment for the details.Before / After
How to test
Expected: with the beta on and the block editor in use, field groups appear in the sidebar and still save. With the beta off, or on a classic editor post type, nothing changes.
For the fixture change, run the E2E suite against WP trunk and expect no preview timeouts. WP 6.9 and WP latest cover the older label and should keep passing:
Testing done
tests/php/EditorSidebarBetaTest.phpfor feature registration, position switching, classic editor fallback, unknown post types and saved order rewrites, plus a check_screen response test.wp-scripts lint-jsclean on the changed fixture.Notes
@wordpress/e2e-test-utils-playwrightto 2.x is the durable fix for the preview label, but 2.x matches only the new label and would break WP 6.2, 6.9 and latest. A helper bump belongs in its own PR.