Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions projects/packages/forms/changelog/fix-forms-wp-build-boot
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Load the wp-build dashboard independently of the Gutenberg plugin.
4 changes: 4 additions & 0 deletions projects/packages/forms/routes/forms/stage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ import DataViewsHeaderRow from '../../src/dashboard/wp-build/components/dataview
import usePageHeaderDetails from '../../src/dashboard/wp-build/hooks/use-page-header-details';
import useConfigValue from '../../src/hooks/use-config-value';
import { INTEGRATIONS_STORE, IntegrationsSelectors } from '../../src/store/integrations';
import './style.scss';
/**
* Types
*/
import type { FormListItem } from '../../src/dashboard/hooks/use-forms-data.ts';
import type { Action, Operator, View } from '@wordpress/dataviews';

Expand Down
2 changes: 2 additions & 0 deletions projects/packages/forms/routes/forms/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@use "sass:meta";
@include meta.load-css("@wordpress/dataviews/build-style/style.css");
2 changes: 2 additions & 0 deletions projects/packages/forms/routes/responses/style.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@use "sass:meta";
@use "@wordpress/base-styles/variables";
@include meta.load-css("@wordpress/dataviews/build-style/style.css");

// Fix for sticky header on mobile in wp-admin
// The header needs to account for the wp-admin bar
Expand Down
21 changes: 14 additions & 7 deletions projects/packages/forms/src/dashboard/class-dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,25 @@
* Handles the Jetpack Forms dashboard.
*/
class Dashboard {

/**
* Load wp-build generated files if available.
* This is for the new DataViews-based responses list.
*/
public static function load_wp_build() {
if ( self::get_admin_query_page() === self::FORMS_WPBUILD_ADMIN_SLUG ) {
$wp_build_index = dirname( __DIR__, 2 ) . '/build/build.php';

if ( file_exists( $wp_build_index ) ) {
require_once $wp_build_index;

// Re-add core's registration only when Gutenberg isn't providing it
if ( ! defined( 'IS_GUTENBERG_PLUGIN' ) || ! IS_GUTENBERG_PLUGIN ) {
// `wp-build` currently removes `wp_default_script_modules` from `wp_default_scripts`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds weird to me why are we doing this in wp-build?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a simple test repo:
https://github.com/dhasilva/minimal-wp-build-test
This fix is applied there, but commented.

// Re-add the core hook so script modules work in vanilla wp-admin (no Gutenberg plugin).
if ( function_exists( 'wp_default_script_modules' ) ) {
add_action( 'wp_default_scripts', 'wp_default_script_modules', 0 );
}
Comment on lines +37 to +41
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New bootstrapping behavior is introduced here (re-adding wp_default_script_modules on wp_default_scripts when Gutenberg isn’t present), but there’s no unit coverage for this load_wp_build() branch. Since Dashboard already has PHPUnit tests, please add a test that exercises this path and asserts the action is (or isn’t) registered as expected.

Copilot uses AI. Check for mistakes.
}
}
}
}
Expand Down Expand Up @@ -65,17 +74,15 @@ public static function load_wp_build() {
* Initialize the dashboard.
*/
public function init() {
add_action( 'admin_menu', array( $this, 'add_new_admin_submenu' ), self::MENU_PRIORITY );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this MENU_PRIORITY anymore for WP Build?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, we don't.


// Flag to enable the wp-build-based dashboard.
$is_wp_build_enabled = apply_filters( 'jetpack_forms_alpha', false );

if ( $is_wp_build_enabled ) {
// Load wp-build generated files for the new DataViews-based UI.
self::load_wp_build();
}

add_action( 'admin_menu', array( $this, 'add_new_admin_submenu' ), self::MENU_PRIORITY );

if ( $is_wp_build_enabled ) {
add_action( 'admin_menu', array( $this, 'add_forms_wpbuild_submenu' ), self::MENU_PRIORITY );
add_action( 'admin_menu', array( $this, 'add_forms_wpbuild_submenu' ) );
}

add_action( 'admin_enqueue_scripts', array( $this, 'load_admin_scripts' ) );
Expand Down
Loading