Problem/Motivation

On Back, a browser that skips its back/forward cache reloads the page and restores the form values. Chrome restores them after Drupal.behaviors.editor has attached. No input or change event fires.

As a result, in Chrome:

  1. The editor shows the stored body. Save stores it and drops the edit.
  2. The text format select shows the restored format, but the old editor stays attached.

In all browsers, data-editor-value-is-changed comes back as "false". On a multi-format field, Drupal.editorDetach() then saves data-editor-value-original.

#153313 reported this for CKEditor 4.

Steps to reproduce

  1. Start Chrome with --disable-back-forward-cache.
  2. Edit a node whose body has a value and more than one text format.
  3. Change the body. Submit so that the response is an error page.
  4. Press Back. The textarea holds the edit. CKEditor shows the original.
  5. Save. The original is stored.

Proposed resolution

In editor.js, on pageshow with persisted false, attach the editor again when the textarea or the select changed. At attach, mark the field as changed when its value differs from defaultValue and data-editor-value-original.

Remaining tasks

  • Review the MR.

Generated with the help of an LLM.

Issue fork drupal-3639725

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

davituri created an issue. See original summary.

davituri’s picture

Status: Active » Needs review