Wysiwyg type fields cause an unsaved data Javascript alert

Abierto
#1,393 9 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
javascript, php, wordpress
Área
frontend

Línea de trabajo

Start by reproducing the issue on WordPress 5.6 with a CMB2 wysiwyg field, following the steps in the report; compare it with a textarea field. The report names no source files or tests, so trace the WYSIWYG field's JavaScript interaction with the post editor and its unsaved-change alert. Done means leaving the post after saving does not trigger an alert when there are no unsaved changes.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Describe the bug

Using a wysiwyg type field causes a JavaScript alert when leaving a post edit screen, even when there are no unsaved changes. This appears to be a new issue in WordPress 5.6, as far as I can tell. The issue does not happen if the type is textarea, only (as far as I can tell) when the type is wysiwyg.

I've been able to reproduce this on the develop branch, in a default WordPress install (version 5.6) with the twentytwentyone theme.

Steps to reproduce (I have confirmed I can reproduce this issue on the develop branch):

  1. Install CMB2
  2. Create a functions.php file with a single wysiwyg field
  3. Edit a new or existing post. Save it (if it's a draft) or publish it (if it's already published).
  4. Click any other link in the admin menu to leave this post.

Possible Solution

Possible Solution's Risk Level

This appears to be admin-only, but it is a big annoyance for admin users when they're editing a lot of posts in a given day, such as on a news website.

Screenshots

If applicable, add screenshots to help explain your problem.
image

CMB2 Field Registration Code:

/**
* Add custom fields to posts
*
*/
if ( ! function_exists( 'cmb2_post_fields' ) ) :

	add_action( 'cmb2_init', 'cmb2_post_fields' );
	function cmb2_post_fields() {

		$object_type = 'post';

		/**
		 * Excerpt settings
		 */
		$excerpt = new_cmb2_box(
			array(
				'id'           => 'cmb2_excerpt',
				'title'        => __( 'Excerpt', 'twentytwentyone_child' ),
				'object_types' => array( $object_type ), // Post type
				'context'      => 'after_editor',
				'priority'     => 'high',
				'show_names'   => false,
			)
		);
		$excerpt->add_field(
			array(
				'id'        => 'excerpt',
				'name'      => __( 'Excerpt', 'twentytwentyone_child' ),
				'desc'      => '',
				'type'      => 'wysiwyg',
				'escape_cb' => false,
				'options'   => array(
					'media_buttons' => false, // show insert/upload button(s)
					'textarea_rows' => 5,
					'teeny'         => true, // output the minimal editor config used in Press This
				),
			)
		);
	}
endif;

Your Environment

Browser name and version: Firefox 83.0 and Chrome 87.0.4280.88
Operating System and version (desktop or mobile): macOS 10.15.7

Additional context

WordPress 5.6

Lenguaje dominante
PHP
Estrellas
3k
Forks
558
Merge medio
12 h 26 min
PR fusionados (30 d)
2

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de CMB2/CMB2

Todos los issues de CMB2/CMB2

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.