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

Falsy unsaved changes message #7267

Open
yuri-g-taboola opened this issue Aug 13, 2024 · 3 comments
Open

Falsy unsaved changes message #7267

yuri-g-taboola opened this issue Aug 13, 2024 · 3 comments
Labels
area: extensions/widgets/markdown type: bug code to address defects in shipped code

Comments

@yuri-g-taboola
Copy link

yuri-g-taboola commented Aug 13, 2024

Describe the bug
The Unsaved changes message appears when you edit and revert the changes.

To Reproduce

  1. configure the CMS to work with gihub backend
  2. start the cms
  3. create a new post and save it
  4. make a change and revert it
  5. The Unsaved Changes doesn't change to Changes Saved

Expected behavior
The Unsaved Changes should be replaced with Changes Saved

Screenshots

Applicable Versions:

  • Decap CMS version: 3.3.2
  • Git provider: GitHub
  • OS: Mac OS Sonoma 14.4
  • Browser version Firefox 129
  • Node.JS version: 20.12.2

CMS configuration
https://github.com/decaporg/decap-cms/blob/main/dev-test/config.yml
with gitthub backend

Additional context

It seems like the issue has been introduced by adding a new line in packages/decap-cms-core/src/backend.ts#entryToRaw method

    let content = format.toFile(entry.get('data').toJS(), fieldsOrder, fieldsComments);
    if (content.slice(-1) != '\n') {
      // add the EOL if it does not exist.
      content += '\n';
    }
    return content;
  }

in #7039 while solving #1382
The addition of the newline is conflicting with the trimming the end of content in markdown widget at https://github.com/decaporg/decap-cms/blob/main/packages/decap-cms-widget-markdown/src/serializers/index.js#L151

  /**
   * Return markdown with trailing whitespace removed.
   */
  return trimEnd(markdown);
@yuri-g-taboola yuri-g-taboola added the type: bug code to address defects in shipped code label Aug 13, 2024
@martinjagodic
Copy link
Member

This is quite a dilemma. return trimEnd(markdown); appears to be there with a reason (introduced in #653), so we should be careful how we approach this.

@LHSnow
Copy link

LHSnow commented Aug 30, 2024

Possibly related to #7142?

@yuri-g-taboola
Copy link
Author

@martinjagodic
I think the by the book solution will be to add the new line in #7093 only for json files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: extensions/widgets/markdown type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

3 participants