Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
angryaxi opened this issue Jul 21, 2022 · 4 comments
Open

Comments

@angryaxi
Copy link

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.

@tw2113
Copy link
Contributor

tw2113 commented Jul 21, 2022

I am able to recreate, but only in classic editor. Block editor provided no issue. I was able to recreate in Block editor too.

It feels like the WYSIWYG aspect for the field gets lost in just one spot, and it's just a standard textarea at that point.

No notable JS errors in the console, that I can see with Firefox. Same thing with Chrome. There are some things from tinymce.min.js directly, but that'd be a WP core thing rather than anything specifically CMB2 did.

@TheNewGuy16
Copy link

I can also confirm that 2.9.0 version of CMB2 the sorting is perfectly fine

@Scorpio256
Copy link

Any news on this issue? I have same problem . Content is lost when position change is made.

@TheNewGuy16
Copy link

TheNewGuy16 commented Oct 9, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants