uniforms icon indicating copy to clipboard operation
uniforms copied to clipboard

Unstyled date field does not suport type date

Open mariusrak opened this issue 2 years ago • 2 comments

When using DateField from uniforms-unstyled and you want only date without time, it is impossible to set value.

You can check within the playground by changing `date field in schema to

    date: { type: Date, defaultValue: new Date(), uniforms: {type: 'date'} },

Seems like it's setting value incorrectly to e.g. 2022-09-08T00:00, while it should probably contain only date and no time information.

mariusrak avatar Aug 31 '22 19:08 mariusrak

Hey there @mariusrak ,

I believe this is a duplicate of #1138 and will most likely be resolved once #1140 is merged. @kestarumper could you confirm if that is true?

wadamek65 avatar Sep 01 '22 08:09 wadamek65

Hi @mariusrak,

When using DateField from uniforms-unstyled and you want only date without time, it is impossible to set value.

It's setting the date in the model (in the form state), but it's not rendered correctly (it's not displaying the date).

Seems like it's setting value incorrectly to e.g. 2022-09-08T00:00, while it should probably contain only date and no time information.

Looking at the code, the value is always normalized to the ISO 8601 standard whenever the field value changes. It uses the toISOString under the hood.

E.g.

new Date("2022-09-25").toISOString()
// '2022-09-25T00:00:00.000Z'

I also checked it on the #1140, and it seems like it's resolved on that branch (see the recording below). It's still setting the model value as the full ISO 8601 string (example above) even if you use type="date" (no time).

https://user-images.githubusercontent.com/13087338/192155979-0a7f9cf6-de82-4710-aecb-9145ba389352.mov

kestarumper avatar Sep 25 '22 17:09 kestarumper