Skip to content

Commit 8009ee2

Browse files
committed
Forms: fix styles not loading at CIAB
1 parent 8571f3a commit 8009ee2

File tree

2 files changed

+6
-30
lines changed

2 files changed

+6
-30
lines changed

projects/packages/forms/src/blocks/contact-form/class-contact-form-block.php

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public static function register_block() {
5252
add_filter( 'pre_render_block', array( __CLASS__, 'pre_render_contact_form' ), 10, 3 );
5353

5454
add_filter( 'block_editor_rest_api_preload_paths', array( __CLASS__, 'preload_endpoints' ) );
55+
56+
// Load scripts for the editing interface
57+
add_action( 'enqueue_block_editor_assets', array( __CLASS__, 'load_editor_scripts' ), 9 );
5558
}
5659
/**
5760
* Register the contact form block feature flag.
@@ -824,26 +827,6 @@ private static function render_synced_form( $ref_id ) {
824827
return $output;
825828
}
826829

827-
/**
828-
* Load editor styles for the block.
829-
* These are loaded via enqueue_block_assets to ensure proper loading in the editor iframe context.
830-
*/
831-
public static function load_editor_styles() {
832-
833-
$handle = 'jp-forms-blocks';
834-
835-
Assets::register_script(
836-
$handle,
837-
'../../../dist/blocks/editor.js',
838-
__FILE__,
839-
array(
840-
'css_path' => '../../../dist/blocks/editor.css',
841-
'textdomain' => 'jetpack-forms',
842-
)
843-
);
844-
wp_enqueue_style( 'jp-forms-blocks' );
845-
}
846-
847830
/**
848831
* Loads scripts
849832
*/
@@ -856,6 +839,8 @@ public static function load_editor_scripts() {
856839

857840
$handle = 'jp-forms-blocks';
858841

842+
wp_enqueue_style( 'jp-forms-blocks' );
843+
859844
Assets::register_script(
860845
$handle,
861846
'../../../dist/blocks/editor.js',
@@ -865,8 +850,7 @@ public static function load_editor_scripts() {
865850
'in_footer' => true,
866851
'textdomain' => 'jetpack-forms',
867852
'enqueue' => true,
868-
// Editor styles are loaded separately, see load_editor_styles().
869-
'css_path' => null,
853+
'css_path' => '../../../dist/blocks/editor.css',
870854
)
871855
);
872856

projects/plugins/jetpack/extensions/blocks/contact-form/contact-form.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,3 @@
1313

1414
// Register the block
1515
add_action( 'init', array( Contact_Form_Block::class, 'register_block' ), 9 );
16-
17-
// Load scripts for the editing interface
18-
add_action( 'enqueue_block_editor_assets', array( Contact_Form_Block::class, 'load_editor_scripts' ), 9 );
19-
20-
// Load styles in the editor iframe context
21-
if ( is_admin() ) {
22-
add_action( 'enqueue_block_assets', array( Contact_Form_Block::class, 'load_editor_styles' ), 9 );
23-
}

0 commit comments

Comments
 (0)