[wp-trac] [WordPress Trac] #55012: TinyMCE editor not rendering correctly in visual mode using wp_editor function in a meta box on a page with the Block editor enabled in WP 5.9

WordPress Trac noreply at wordpress.org
Mon Jan 31 17:51:40 UTC 2022


#55012: TinyMCE editor not rendering correctly in visual mode using wp_editor
function in a meta box on a page with the Block editor enabled in WP 5.9
----------------------------+-----------------------------
 Reporter:  rickcurran      |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  TinyMCE         |    Version:  5.9
 Severity:  major           |   Keywords:
  Focuses:  ui, javascript  |
----------------------------+-----------------------------
 Using the wp_editor function on a meta box on WP 5.9 with the block editor
 enabled on a page results in the TinyMCE editor not rendering correctly in
 Visual mode.

 I note that there are several prior tickets about this same issue which
 unfortunately seem to have been unresolved due to being unable to be
 reproduced consistently: [https://core.trac.wordpress.org/ticket/52133
 #52133], [https://core.trac.wordpress.org/ticket/52050 #52050],
 [https://core.trac.wordpress.org/ticket/53644 #53644].

 Sadly I am also unable to reproduce this bug consistently either, I am
 experiencing it on both the development version and live versions of a
 particular site I'm working on at the moment, prior to the 5.9 update the
 wp_editor had been working correctly on both of these sites. As a test I
 made two clean installations on another server of both 5.8 and 5.9 with no
 additional plugins and a simple theme with metabox added to it and the
 wp_editor works correctly. So there is something specific about the
 particular combination of code in my site that is preventing the wp_editor
 from working in visual mode that didn't seem to be occurring before 5.9
 for some reason, even though on these simple test installations they seem
 to be fine.

 I am able to workaround the issue by the following steps: switch to the
 Text view tab in the wp_editor, refresh the page and then switch back to
 the Visual view tab. These steps were indicated in one of the previous
 tickets linked above.

 The following is an example of the code I am using to add the metabox with
 wp_editor in it:


 {{{
 function tools_next_steps_metabox() {
         global $post;

         $custom = get_post_custom( $post->ID );
         $next_steps_links = isset( $custom[ 'next_steps_links' ][0] ) ?
 $custom[ 'next_steps_links' ][0] : '';

         echo '<ul>';
         echo '<li>This panel allows entering of text content for the “Next
 Steps” stage of the tool.</li>';
         echo '<li>';
         wp_editor( $next_steps_links, 'next_steps_links_id', array(
                 'wpautop' => true,
                 'tinymce' => array(
                         'toolbar1' => 'bold,italic,bullist,link,unlink',
                 ),
                 'media_buttons' => false,
                 'quicktags' => array(
                         'buttons' => 'strong,em,underline,ul,li,link'
                 ),
                 'textarea_name' => 'next_steps_links',
                 'textarea_rows' => get_option('default_post_edit_rows',
 10),
                 'teeny' => true,

         ) );
         wp_editor( $next_steps_links, 'next_steps_links_id' );
         echo '</li>';
         echo '</ul>';
 }

 add_action( 'add_meta_boxes', 'render_page_metaboxes' );
 function render_page_metaboxes() {
         add_meta_box( 'a_tools_next_steps_metabox', 'Next Steps',
 'tools_next_steps_metabox', 'page', 'normal', 'low' );
 }
 }}}

 I appreciate this is perhaps not the most helpful ticket but given that
 issue has been reported in the past there is obviously some circumstance
 where using metaboxes and the wp_editor on pages using the block editor
 results in the editor not getting activated on load when the wp_editor is
 in visual mode. On the pages where I have the error occurring I have tried
 disabling the block editor on those pages and the wp_editor works
 correctly when the block editor is disabled.

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


More information about the wp-trac mailing list