Skip to content

Reordering wysiwyg fields inside a group causes a problem with TinyMCE #1461

Description

@angryaxi

Describe the bug

Reordering wysiwyg fields inside a group causes buggy behavior with TinyMCE, which breaks the saving of the field content.

Steps to reproduce (I have confirmed I can reproduce this issue on the develop branch): Yes, reproduced on develop [e39ae3b]

  1. Install WordPress
  2. Install the following plugins: Classic Editor, Classic Widgets, CMB2
  3. Register metaboxes with the code provided below
  4. Create a new page
  5. Add three rows inside the group with some content
  6. Save the page
  7. Move the last row to be the first
  8. See that the second row's TinyMCE editor has bugged out. Highlighting the text area inside it reveals the content, however saving the page causes the content to disappear. Clicking on the tabs of the bugged out field changes tabs on the first field.

Screenshots

r0EIhUGVbO

CMB2 Field Registration Code:

function register_cmb2_test_metaboxes() {
    $test_metabox = new_cmb2_box(array(
        'id' => 'test_metaboxes',
        'title' => 'Testing metaboxes',
        'object_types' => array('page'),
        'show_names' => true,
    ));

    $test_group = $test_metabox->add_field(array(
        'id' => 'test_group',
        'type' => 'group',
        'options' => array(
            'group_title' => 'Row {#}',
            'add_button' => 'Add row',
            'remove_button' => 'Remove row',
            'sortable' => true
        )
    ));

    $test_metabox->add_group_field($test_group, array(
        'id' => 'row_content',
        'name' => 'Text content',
        'type' => 'wysiwyg'
    ));
}
add_action('cmb2_admin_init', 'register_cmb2_test_metaboxes');

Your Environment

Browser name and version: Firefox 102.0.1 (64-bit)
Operating System and version (desktop or mobile): Windows 10 21H2

wp-core

version: 6.0.1
site_language: en_US
user_language: en_US
timezone: +00:00
permalink: /%year%/%monthnum%/%day%/%postname%/
https_status: false
multisite: false
user_registration: 0
blog_public: 0
default_comment_status: open
environment_type: local
user_count: 1
dotorg_communication: true

wp-active-theme

name: Twenty Twenty-Two (twentytwentytwo)
version: 1.2
author: the WordPress team
author_website: https://wordpress.org/
parent_theme: none
theme_features: core-block-patterns, post-thumbnails, responsive-embeds, editor-styles, html5, automatic-feed-links, block-templates, widgets-block-editor, wp-block-styles, editor-style
theme_path: D:\xampp\htdocs\cmb2-bugreport/content/themes/twentytwentytwo
auto_update: Disabled

wp-mu-plugins (1)

cmb2 test code: version: 1.0

wp-plugins-active (3)

Classic Editor: version: 1.6.2, author: WordPress Contributors, Auto-updates disabled
Classic Widgets: version: 0.3, author: WordPress Contributors, Auto-updates disabled
CMB2: version: 2.10.1, author: CMB2 team, Auto-updates disabled

wp-server

server_architecture: Windows NT 10.0 AMD64
httpd_software: Apache/2.4.48 (Win64) OpenSSL/1.1.1k PHP/7.4.20
php_version: 7.4.20 64bit
php_sapi: apache2handler
max_input_variables: 1000
time_limit: 120
memory_limit: 512M
max_input_time: 60
upload_max_filesize: 128M
php_post_max_size: 128M
curl_version: 7.70.0 OpenSSL/1.1.1k
suhosin: false
imagick_availability: false
pretty_permalinks: true

wp-database

extension: mysqli
server_version: 10.4.19-MariaDB
client_version: mysqlnd 7.4.20
max_allowed_packet: 1048576
max_connections: 151

Additional context

Downgrading CMB2 to version 2.9.0 fixes this problem. This bug first appeared in version 2.10.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions