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

Date widget inside list widget not showing default date value #1117

Closed
thebetternewt opened this issue Feb 18, 2018 · 8 comments
Closed

Date widget inside list widget not showing default date value #1117

thebetternewt opened this issue Feb 18, 2018 · 8 comments

Comments

@thebetternewt
Copy link

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

- What is the current behavior?

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

- What is the expected behavior?

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

- Please link or paste your config.yml below if applicable.

I have a list widget with each item containing multiple date fields. However, all date fields other than the last field are initially blank instead of showing the default value (the current date in this case). I am using CMS version 1.2.0 according to my browser console.

Here is a link to my config.yml:

config.yml

@louMoxy
Copy link

louMoxy commented Mar 24, 2018

Hi @thebetternewt
I have just tried to replicate the problem, but I don't see any issues. All the dates are displaying as expected. Are you still having issues?

@erquhart
Copy link
Contributor

This seems to be fixed in 1.3.5, not sure where the fix actually occurred. Please comment if you're still able to reproduce.

@thebetternewt
Copy link
Author

Hi. Sorry for the delayed response. Yes I thought this issue was already confirmed and fixed. I did not realize the issue was still open. It has been working for a while now. Thanks your your help!

@tech4him1
Copy link
Contributor

tech4him1 commented Apr 16, 2018

I can still reproduce this in v1.5.0 using the original config, although I couldn't in v1.3.5. I'm guessing the fix was a side effect of the regression fixed in #1210. Unfortunately, fixing that regression broke this again.

collections:
  - label: "Settings"
    name: "Settings"
    files:
      - name: "date_settings"
        label: "Date Settings"
        file: "data/date_settings.json"
        description: "Set blackout dates"
        fields:
          - label: "Blackout Dates"
            name: "blackout_dates"
            widget: "list"
            fields:
              - {label: "Note", name: "note", widget: "string"}
              - {label: "Start Date", name: "start_date", widget: "date"}
              - {label: "End Date", name: "end_date", widget: "date"}

@tech4him1 tech4him1 reopened this Apr 16, 2018
@tech4him1
Copy link
Contributor

tech4him1 commented Apr 17, 2018

When a new list item is created, the Date widget calls onChange to set its default.

The nested default is set using this code:
https://github.com/netlify/netlify-cms/blob/1a3454f244b1e1a190f24fe2acfb9b1583446bc6/src/components/EditorWidgets/List/ListControl.js#L163

For some reason, when the list is first being created, getObjectValue returns an empty Map on every call, so instead of adding the new value to the Map, only the one just set remains. Therefore, when there are multiple widgets in the list item, only the last one will have remain (1 will overwrite 2, 2 will overwrite 3, etc.).

Is the Redux action asynchronous in this case? If so, when we call onChange (DRAFT_CHANGE_FIELD), it's not necessarily going to update before the next widget sets its value.

@barthc
Copy link
Contributor

barthc commented Nov 13, 2018

@erquhart can we now close this?

@barthc
Copy link
Contributor

barthc commented Dec 12, 2018

@erquhart ping!!!

@erquhart
Copy link
Contributor

@barthc sorry about that, yes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants