Netlify-cms: New entries with a Date field show changed status

Created on 23 Oct 2017  路  11Comments  路  Source: netlify/netlify-cms

- Do you want to request a feature or report a bug?
bug

- What is the current behavior?
Entries with a Date field will ask the user whether or not they want to save changes, when the entry was just created.

- If the current behavior is a bug, please provide the steps to reproduce.

  1. Create a new entry (with a Date field).
  2. Try to leave it (click the home button).

- What is the expected behavior?
If nothing has been added, the entry should not prompt to save.

- Please mention your CMS, node.js, and operating system version.

0.5.1 (actually master)

bug pinned

Most helpful comment

We could also provide a setDefault function via props, would be a bit cleaner that way.

All 11 comments

This happens with the Relation Widget also, even on existing entries. It is due to the way widgets dynamically set their inital state -- widgets that do not set inital state (most) do not cause this bug.

The way I see to fix that would be to provide a "default default", maybe static default = new Date() on the widget, that the widget registry checks for if no default is set.

We could also provide a setDefault function via props, would be a bit cleaner that way.

As per PR just created - we've encountered a similar issue to that reported here where the inclusion of a relation widget in the editor page causes an article to require hitting the save button twice to save the article. This seems to be because the setting of metadata in the a DRAFT_CHANGE_FIELD signal is changing hasChanged attribute in the entry state to be true even though the value has not changed at all.

I'm new to the internals of Netlify CMS and various logic flows, but I'm wondering whether the metadata changing should really be indicating that entry has changed, or whether this meta data is just used for the CMS interface. Any guidance on any side effects not setting hasChange to true when only meta data set would be appreciated to help me steer to the correct solution.

Just updated the PR above so now preview - https://deploy-preview-2377--cms-demo.netlify.com/ - allows you to create new post / edit post / new kitchen sink / edit kitchen sink, with the hasChanged flag not being set on load of the first screen (i.e. no changes to save wrongly detected) , and that flag is only changed with you actually make some content changes.

Awesome, I'll take a look soon!

Any updates on this?

The right approach is going to involve widgets setting their own default values and directly reporting clean/dirty status, which means some API additions - this requires communication and agreement about approach before a PR is opened.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Just curious, is there a workaround until this PR gets merged?

The relation field status change already fixed here #3306, we are now only dealing with the date widget.

Was this page helpful?
0 / 5 - 0 ratings