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

Datetime Widget Displays current Datetime when field is empty #3679

Closed
Undistraction opened this issue Apr 30, 2020 · 4 comments
Closed

Datetime Widget Displays current Datetime when field is empty #3679

Undistraction opened this issue Apr 30, 2020 · 4 comments
Labels
area: extensions/widgets/datetime type: bug code to address defects in shipped code

Comments

@Undistraction
Copy link
Contributor

Undistraction commented Apr 30, 2020

Describe the bug
I just tried to switch us over from the Date widget to the Datetime widget, however, it appears the Datetime widget will always display the current date/time, even if the field has no value.

This makes it look like the field has a value when it does not and is very confusing for users.

To Reproduce

  1. Create a field with a widget type of 'datetime'.
  2. Set a default value of '' or do not set a default value.

Expected behavior
The widget should behave the same as the Date widget, showing a blank field until the field is clicked into.

Applicable Versions:

  • Netlify CMS version: 2.12.11
  • Browser version Version 81.0.4044.129 (Official Build) (64-bit)
@Undistraction Undistraction changed the title Datetime Widget Displays current Date time when field is empty Datetime Widget Displays current Datetime when field is empty Apr 30, 2020
@erezrokah erezrokah added type: bug code to address defects in shipped code area: extensions/widgets labels Apr 30, 2020
@erezrokah
Copy link
Contributor

Hi @Undistraction, can you share a config file? I'm using:

backend:
  name: test-repo

media_folder: assets/uploads

collections: # A list of collections the CMS should be able to edit
  - name: 'posts' # Used in routes, ie.: /admin/collections/:slug/edit
    label: 'Posts' # Used in the UI
    label_singular: 'Post' # Used in the UI, ie: "New Post"
    folder: '_posts'
    create: true # Allow users to create new documents in this collection
    fields: # The fields each document in this collection have
      - { label: 'Title', name: 'title', widget: 'string', tagname: 'h1' }
      - {
          label: 'Publish Date',
          name: 'date',
          default: '',
          widget: 'datetime',
          dateFormat: 'YYYY-MM-DD',
          timeFormat: 'HH:mm',
          format: 'YYYY-MM-DD HH:mm',
        }

And getting:
image

@Undistraction
Copy link
Contributor Author

@erezrokah Sorry. Had to roll-back to using the date widget. I'll find some time in the next week and put together a repro.

@aminimalanimal
Copy link

aminimalanimal commented Nov 5, 2021

@erezrokah
You should be able to reproduce this by removing format from your configuration. When Netlify CMS’ default is used, it populates the field with the user’s current date.

martinjagodic added a commit that referenced this issue Aug 12, 2024
- don't display the current date by default or when the field is empty (#3679) - **potentially breaking change**
- add `default: '{{now}}'` option to enable the current behavior of displaying the current time (using the specified format)
- add UTC indicator when `picker_utc: true`
- improve how `Z` in format and `picker_utc: true` work together
- reorder format importance: if `format` is set, `date_format` and `time_format` (if strings) are ignored (#7250)

BREAKING CHANGE: The datetime field is empty by default, from now on, but it was prefilled with the current date until now. Use `default: '{{now}}'` to prefill the field with the current date.
@martinjagodic
Copy link
Member

Done in #7261

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

No branches or pull requests

4 participants