Skip to content

There is a flash of HTML when submitting a form with CKEditor5 #7149

@swampopus

Description

@swampopus

Description of the bug

When editing any content type that uses CKEditor5, when you click 'Save', the editor is destroyed and you can see a flash of plain HTML where the editor used to be. This looks funky and confuses less-savvy users.

See video which demonstrates the behavior on a clean install:

ckeditor_html_flash.webm

Steps To Reproduce

To reproduce the behavior:

  1. Create a clean install of Backdrop (optional)
  2. Click to "Create Page"
  3. Make sure the editor is set to Basic, and using CKEditor for the Body field.
  4. Type anything into the Body field
  5. Save, and watch closely, you will see a flash of HTML.

Actual behavior

See video above.

Solution!

There's no reason to destroy the editor (line 123 of core/modules.ckeditor5/js/ckeditor5.js) if the form is being submitted anyway.

I have a kludge/hack that actually fixes this; will submit a PR shortly. Basically, I set a variable if I know the form is submitting, then, in ckeditor5.js, I only call editor.destroy() if we are NOT submitting the form. This works in my case, but I don't know if it works in all situations.

Additional information

Add any other information that could help, such as:

  • Backdrop CMS version: 1.34.0
  • Web server and its version: Apache 2.4.65
  • PHP version: 8.1.34
  • Database sever (MySQL or MariaDB?) and its version: MariaDB 10.7.8
  • Operating System and its version: Debian
  • Browser(s) and their versions: Chrome 148

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions