meta-box icon indicating copy to clipboard operation
meta-box copied to clipboard

Metabox group: wysiwig content replaced with post content after deactivate Classic Editor

Open SimonvanWijhe opened this issue 4 years ago • 5 comments

Issue Overview

Metabox group: wysiwig content replaced with post content after deactivate Classic Editor.

Steps to Reproduce (for bugs)

  1. Add the following code to functions.php:
add_filter('rwmb_meta_boxes', 'meta_box_group_demo_register');
function meta_box_group_demo_register($meta_boxes)
{
    $meta_boxes[] = array(
        'title'  => 'Demo group',
        'fields' => array(
            array(
                'id'     => 'standard',
                'type'   => 'group',
                'clone'  => true,
                'sort_clone' => true,
                'fields' => array(
                    array(
                        'name' => 'Demo field',
                        'id' => 'demo-field',
                        'type' => 'wysiwyg',
                        'options' => array(
                            'textarea_rows' => 4,
                        ),
                    )
                ),
            ),
        ),
    );
    return $meta_boxes;
}
  1. Install "Classic Editor" plugin by Wordpress Contributors
  2. Create a post.
  3. Add some post content.
  4. Add content to demo field.
  5. Click 'Add more'
  6. Add content to second demo field.
  7. Switch the demo fields around.

Expected Behavior

Expect the group fields to display their content, as before moving it.

Current Behavior

The content of the group fields are replaced with the post content.

Screenshots / Video

demo-wysiwyg-group-classic-editor

Additional information:

  • Related issue: https://github.com/wpmetabox/meta-box/issues/1376

  • Wordpress 5.4.2

  • Pugins: Metabox, Metabox Group, Classic Editor

  • Theme: twentytwenty

  • Browser: Chrome version:83.0.4103.116

  • MacOS

SimonvanWijhe avatar Jul 27 '20 08:07 SimonvanWijhe

This is a annoying bug. We also have the same issue.

I've traced it down to the file js/clone.js and specific line 245:

tinymce.execCommand( 'mceAddEditor', true, this.id );

When removing this line, the drag and drop is successful, however the tab visual is switch to text, and the editor show the html instead of the styled text.

Hope this helps the journey into this bug.

edwinsiebel avatar Aug 14 '20 09:08 edwinsiebel

Adding editor.execCommand('mceSetContent', false, this.id); above tinymce.execCommand( 'mceAddEditor', true, this.id ); (line 245) does seem to fix the problem of the content being swapped.

The tabs are still scambled (see my previous post)

edwinsiebel avatar Aug 14 '20 09:08 edwinsiebel

@edwinsiebel What is 'editor' in editor.execCommand('mceSetContent', false, this.id);?

viet34tqc avatar Aug 18 '20 04:08 viet34tqc

@viet34tqc , never mind my reaction. The editor.execCommand('mceSetContent', false, this.id); returns an error, so that's why tinymce.execCommand( 'mceAddEditor', true, this.id ); was not executed, and thus that 'fixes' what I wrote in https://github.com/wpmetabox/meta-box/issues/1381#issuecomment-673975100.

edwinsiebel avatar Aug 18 '20 08:08 edwinsiebel

Any research or improvements on this post?

edwinsiebel avatar Aug 25 '20 06:08 edwinsiebel