meta-box
meta-box copied to clipboard
Metabox group: wysiwig content replaced with post content after deactivate Classic Editor
Issue Overview
Metabox group: wysiwig content replaced with post content after deactivate Classic Editor.
Steps to Reproduce (for bugs)
- 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;
}
- Install "Classic Editor" plugin by Wordpress Contributors
- Create a post.
- Add some post content.
- Add content to demo field.
- Click 'Add more'
- Add content to second demo field.
- 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
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
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.
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
What is 'editor' in editor.execCommand('mceSetContent', false, this.id);
?
@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.
Any research or improvements on this post?