AlchemyCMS / alchemy_cms

Alchemy is the Open Source Rails CMS framework for the component based web that can be used as classic server side rendered or headless CMS.
https://www.alchemy-cms.com
BSD 3-Clause "New" or "Revised" License
846 stars 315 forks source link

resource date input gets pre populated with current date when editing / creating a record #2132

Closed robinboening closed 2 years ago

robinboening commented 3 years ago

Steps to reproduce

Prerequisite: A resource model with a date attribute

  1. create or update a record for the resource

Expected behavior

The input field for the date attribute should be left empty (unless it had a value stored in the db).

Actual behavior

The input field for the date attribute is set to the current date.

I think flatpickr populates the input field.

System configuration

tvdeyen commented 3 years ago

Seems to be flatpickr. We set the value to be nil if there is no date https://github.com/AlchemyCMS/alchemy_cms/blob/6f6f47720a34cf45d6b4030c53d63d6a4e2df537/app/helpers/alchemy/admin/base_helper.rb#L320-L328

Not sure how to resolve this. Maybe there is a newer version or a setting we can use?

robinboening commented 3 years ago

I haven't confirmed, but I found this code where flatpickr gets initialised with a certain configuration:

https://github.com/AlchemyCMS/alchemy_cms/blob/953abfa6370f4f294ed77cc7b321c1c6f85d8cbe/app/assets/javascripts/alchemy/alchemy.datepicker.js.coffee#L14-L27

Maybe (also unconfirmed) flatpickr sets the current date by default, but I found the configuration defaultDate : null which can be added. I am not sure if this has unintended side effects though.

robinboening commented 3 years ago

flatpickr already defaults to null on the defaultDate option. My assumption was wrong. Source: https://flatpickr.js.org/options/

tvdeyen commented 2 years ago

Is this still an issue after we merged #2197

github-actions[bot] commented 2 years ago

This issue has not seen any activity in a long time. Please create a pull request with a fix or ask someone of the community if they can help. This issue will be closed in 7 days if no further activity happens.

github-actions[bot] commented 2 years ago

This issue has not seen any activity in a long time. If the issue described still exists in recent versions of Alchemy, please open a new issue with. Thanks for reporting.