diff --git a/projects/packages/forms/changelog/fix-forms-wp-build-boot b/projects/packages/forms/changelog/fix-forms-wp-build-boot new file mode 100644 index 000000000000..d13066a14569 --- /dev/null +++ b/projects/packages/forms/changelog/fix-forms-wp-build-boot @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Load the wp-build dashboard independently of the Gutenberg plugin. diff --git a/projects/packages/forms/routes/forms/stage.tsx b/projects/packages/forms/routes/forms/stage.tsx index 3693ed562873..f8bc2aaacd1f 100644 --- a/projects/packages/forms/routes/forms/stage.tsx +++ b/projects/packages/forms/routes/forms/stage.tsx @@ -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'; diff --git a/projects/packages/forms/routes/forms/style.scss b/projects/packages/forms/routes/forms/style.scss new file mode 100644 index 000000000000..0ad092c7055d --- /dev/null +++ b/projects/packages/forms/routes/forms/style.scss @@ -0,0 +1,2 @@ +@use "sass:meta"; +@include meta.load-css("@wordpress/dataviews/build-style/style.css"); diff --git a/projects/packages/forms/routes/responses/style.scss b/projects/packages/forms/routes/responses/style.scss index a2979f7cf631..e957fa2e8c87 100644 --- a/projects/packages/forms/routes/responses/style.scss +++ b/projects/packages/forms/routes/responses/style.scss @@ -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 diff --git a/projects/packages/forms/src/dashboard/class-dashboard.php b/projects/packages/forms/src/dashboard/class-dashboard.php index aef968cc1249..f4d366316a22 100644 --- a/projects/packages/forms/src/dashboard/class-dashboard.php +++ b/projects/packages/forms/src/dashboard/class-dashboard.php @@ -21,7 +21,6 @@ * Handles the Jetpack Forms dashboard. */ class Dashboard { - /** * Load wp-build generated files if available. * This is for the new DataViews-based responses list. @@ -29,8 +28,18 @@ class Dashboard { 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`. + // 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 ); + } + } } } } @@ -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 ); + + // 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' ) );