Skip to content

Code block with language annotation causes report of unsaved changes #7431

@sebduggan

Description

@sebduggan

Describe the bug
When loading a collection item into the editor which has a code block with a language mode set on it, the editor will report that there are "unsaved changes".

However, if you save the item, no change will be made to the source document, even though it has reported that there is an unsaved change.

To Reproduce

  1. Open a collection item for editing which has a field with a markdown widget
  2. Add a code block to the field using the visual editor. In the code settings, assign a language using the "mode" option
  3. Save the post, then reopen it
  4. Note that the "Unsaved changes" message is displayed at top left

Note that the content is correctly saved with the language attribute, e.g.:

```java
// some code in here
```

Expected behavior
We should see "Changes saved" in the top left corner. If no language mode is set on the code, we do not see the issue.

Applicable Versions:

  • Decap CMS version: 3.6.2
  • Git provider: GitLab or local
  • OS: MacOS 15.3.2
  • Browser version: Firefox Developer 137
  • Node.JS version: 23.10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugcode to address defects in shipped code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions