[wp-trac] [WordPress Trac] #53569: Block widgets editor is hidden if a block enqueues 'wp-edit-post' stylesheet

WordPress Trac noreply at wordpress.org
Thu Jul 1 03:04:28 UTC 2021


#53569: Block widgets editor is hidden if a block enqueues 'wp-edit-post'
stylesheet
--------------------------+-----------------------------
 Reporter:  dlh           |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Widgets       |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 On a client site of mine, a custom block has been developed whose
 `editor_style` includes `wp-edit-post` as a dependency.

 When this block loads in the block widgets editor, and the `wp-edit-post`
 stylesheet is enqueued, then a CSS rule is added that causes the editor to
 be hidden. Specifically:

 {{{#!css
 body.block-editor-page #wpbody-content > div:not(.block-editor):not
 (#screen-meta) {
     display: none;
 }
 }}}

 This example block registration should demonstrate the issue:

 {{{#!php
 <?php

 add_action(
         'init',
         function () {
                 wp_register_style(
                         'my-block-style',
                         'https://example.com',
                         array( 'wp-edit-post' )
                 );

                 register_block_type(
                         'my-namespace/my-block',
                         array(
                                 'editor_style' => 'my-block-style',
                         )
                 );
         }
 );
 }}}

 Although it also seems to be as simple as:

 {{{#!php
 <?php

 add_action(
         'init',
         function () {
                 wp_enqueue_style( 'wp-edit-post' );
         }
 );
 }}}

 I'll defer to the editor team as to whether using `wp-edit-post` as a
 style dependency is doing it wrong.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53569>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list