Angular Material renderers - A Bug and an Error

Hello!

Using

  • Angular 7 with jsonforms/core@2.3.0 / jsonforms/angular-material@2.3.0

  • Angular 9 with jsonforms/core@2.4.0 / jsonforms/angular-material@2.4.0

Given a very simple data object and schemas

{ "today": "" }

{
  "type": "object",
  "properties": { "today": { "type": "string", "format": "date" } }
}

{
  "type": "VerticalLayout",
  "elements": [{ "type": "Control", "scope": "#/properties/today" }]
}

Expectation 1 (Possibly a Bug - possibly me not finding the correct documentation)

  • When I pick a date (for example 9/1/2020 (US format)) that the date displayed is 9/1/2020.

Reality

  • When I pick a date, the date that is displayed is the PRIOR day.

  • I assume this is a locale issue, but I am not sure how to fix this.

Expectation 2 (Error condition)

  • When I remove the date from the input box that there are no errors

Reality

  • When I delete the date from the input box I get Cannot read property ‘toISOString’ of null

  • This is because in the DateControlRenderer this line is not checking for a valid value in event.value:

  • getEventValue = (event: any) => event.value.toISOString().substr(0, 10);

Please advise on how to resolve these issues. I don’t currently see issues reported for these items on github, so if they are bugs I can open an issue.

Thanks so much!!

[original thread by Thad Peiffer]

Hi @specantt ,
so the date showing the previous date is definitely a bug and the reason is the conversion to the ISO date which is UTC. I assume you have a north american time zone. Could you please open an issue for this?
If you remove the date there will be no error if you use your schema. The reason is that the date is not required. So if you use a schema like this:

{
  "type": "object",
  "properties": { "today": { "type": "string", "format": "date" } },
  "required": ["today"]
}

you should have a validation error.
Nonetheless there should be a null check before the toIsoString() call. Could you please open a separate issue for this, too?
Thank you very much.
We are also happy to accept contributions :wink: .

[Thad Peiffer]

Thank you, @eneufeld(eneufeld) !

You are correct - I’m in North America. I though perhaps there was a configuration where I could set offset from UTC.

Also, in my case the date wasn’t a required field, so I wasn’t worried about not getting a validation error. I was only concerned about the exception being thrown in the JavaScript.

I’ll file bug reports. Would love to contribute - have done so before on open source projects. In reality, though, not sure if I can due to deadlines. I’m sure you know how that is! :frowning: