Skip to content

Add opt-in editor sidebar for field groups (beta) - #548

Open
faisalahammad wants to merge 2 commits into
WordPress:trunkfrom
faisalahammad:enhancement/154-editor-sidebar
Open

faisalahammad wants to merge 2 commits into
WordPress:trunkfrom
faisalahammad:enhancement/154-editor-sidebar

Conversation

@faisalahammad

@faisalahammad faisalahammad commented Sep 24, 2026 •

Copy link
Copy Markdown

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 side meta 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.php included a class file that does not exist and had an empty registry, so the editor_sidebar feature could never appear. It now loads class-scf-beta-feature-editor-sidebar.php and registers it. The feature shows up as "Move Elements to Editor Sidebar" under Field Groups > Beta Features.

Sidebar placement. includes/api/api-helpers.php adds three scf_ helpers. scf_field_groups_use_editor_sidebar() returns true only when the beta is on and use_block_editor_for_post_type() accepts the post type. includes/forms/form-post.php uses it to switch the meta box context of groups positioned normal, advanced or acf_after_title to side, keeping the existing acf/input/meta_box_priority filter and core priority.

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.php and includes/ajax/class-acf-ajax-check-screen.php rewrite that option for the affected box IDs, same approach as the existing acf_after_title handling in ACF_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.js is 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.0 helper 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

// Before: position was used as configured
$context = esc_attr( $field_group['position'] );

// After: eligible groups move to the sidebar when the beta is on
$context = esc_attr( scf_get_field_group_meta_box_position( $post_type, $field_group['position'] ) );

How to test

  1. Install and activate the plugin.
  2. Go to Field Groups > Beta Features and enable "Move Elements to Editor Sidebar".
  3. Edit a post that has a field group positioned Normal or After Title.
  4. Confirm the fields render in the editor sidebar and save correctly.
  5. Disable the beta and confirm the fields return to the main editor area.

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:

WP_ENV_CORE=WordPress/WordPress npm run test:e2e

Testing done

  • PHPUnit: 2955 tests, 22776 assertions, all pass. New coverage in tests/php/EditorSidebarBetaTest.php for feature registration, position switching, classic editor fallback, unknown post types and saved order rewrites, plus a check_screen response test.
  • Jest: 954 tests pass. Production build compiles.
  • phpcs and PHPStan clean on the changed files, both run through the changed-lines checks used in CI.
  • wp-scripts lint-js clean on the changed fixture.
  • Manual testing of the built zip against the block editor, behaviour confirmed.

Notes

  • The set of eligible field types is not defined by the issue. Anything the classic meta box renderer supports is moved as-is; no field type is excluded in this change.
  • Version tags are not added to the new functions since the next release version is not settled.
  • Bumping @wordpress/e2e-test-utils-playwright to 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.

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
@github-actions

Copy link
Copy Markdown

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props faisalahammad.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant