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

Datepicker in EssenceDate cannot consume localized date format #1245

Closed
gilgor opened this issue Mar 7, 2017 · 3 comments
Closed

Datepicker in EssenceDate cannot consume localized date format #1245

gilgor opened this issue Mar 7, 2017 · 3 comments
Milestone

Comments

@gilgor
Copy link
Contributor

gilgor commented Mar 7, 2017

EssenceDate should always provide the ISO-8601 time format for the datepicker, e.g. 2017-03-07. Otherwise jquery.datetimepicker cannot handle the localized date format (when using another locale than EN in the backend interface).

screen shot 2017-03-07 at 17 41 52

We will have a closer look at it this week and provide a fix.

@robinboening
Copy link
Contributor

robinboening commented Mar 10, 2017

I investigated this issue now - and after two hours of debugging I found that this is not related to the jquery datepicker but to chrome!

This issue only appears when you are using a type date field. What happens is that google chrome creates its own datepicker when you have a type date field but it complains if the date format is not as it expects it to be and as the result is that it doesn't fill in the given date - that is why the field is empty when you (re)load the page.

developer tools - http localhost 3000 admin pages 8 edit 2017-03-10 02-37-53

Related links:

Unfortunately the tests in Alchemy are not able to catch the issue because the value of the date field is set correctly, but its not visible to the user.


The solution for Alchemy is fairly simple:
Instead of rendering a date type field, we can just render a text field. That fixes the issue.

Edit: Its not that simple... for example in iOS the correct interface for picking the date is shown if the field is from the correct type. Changing to type text would stop iOS from doing that.

Edit 2: Actually Alchemy replaces the date type with text already if its not iOS. https://github.com/AlchemyCMS/alchemy_cms/blob/master/app/assets/javascripts/alchemy/alchemy.datepicker.js.coffee#L26-L27 but chrome comes first, does not accept the value and throws the warning.

robinboening added a commit that referenced this issue Mar 10, 2017
- [x] Refactor the way the datepicker is initialized

This change fixes an issue that appears when you are using a type `date` field. What happens is that google chrome renders its HTML5 input field for dates but complains if the date format is not the same as defined in the users OS settings. You can still save new values, but since the values are localized by Rails they are not being presented in the input field (happens when you enter the page or reload). #1245
@robinboening
Copy link
Contributor

I came up with a proposal:

  • Always render the input fields with type text
  • On iOS we switch the attribute to the appropriate type (date/datetime/time)

PR: #1246

robinboening added a commit that referenced this issue Mar 20, 2017
- [x] Refactor the way the datepicker is initialized

This change fixes an issue that appears when you are using a type `date` field. What happens is that google chrome renders its HTML5 input field for dates but complains if the date format is not the same as defined in the users OS settings. You can still save new values, but since the values are localized by Rails they are not being presented in the input field (happens when you enter the page or reload). #1245
@moritzps
Copy link

This was merged in this PR so I will close this issue.

@moritzps moritzps added this to the 3.6 milestone Nov 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants