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

DateTimeField Does not seem to initialize from existing value #451

Open
timbl opened this issue Nov 21, 2021 · 2 comments
Open

DateTimeField Does not seem to initialize from existing value #451

timbl opened this issue Nov 21, 2021 · 2 comments
Labels

Comments

@timbl
Copy link
Contributor

timbl commented Nov 21, 2021

According to solid-ui/Documentation/form-examples/demo.html at any rate.
image

@timbl
Copy link
Contributor Author

timbl commented Nov 22, 2021

This one is not obvious. The input field.value get set to the string in the data, but then when read back, field.value is "" .

@josephguillaume
Copy link

It seems the problem is that a datetime-local input field only accepts Local date and time strings, i.e. without the Z at the end.

In Chrome a warning is thrown here:
https://github.com/solid/solid-ui/blob/c4ad302f361cc4a1de24941a475cb66333c43805/src/widgets/forms/basic.ts#L155

The specified value "2021-10-12T12:34:23Z" does not conform to the required format. The format is "yyyy-MM-ddThh:mm" followed by optional ":ss" or ":ss.SSS".

To get the example to work (https://solid.github.io/solid-ui/Documentation/form-examples/demo.html), it is sufficient to delete the Z.

The solution to this bug is not obvious.
As a starting point, we could change the validation pattern to require the Z to be missing
https://github.com/solid/solid-ui/blob/c4ad302f361cc4a1de24941a475cb66333c43805/src/widgets/forms/fieldParams.ts#L47

However, this leaves support for xsd:dateTime incomplete. (Admittedly other timezone offsets weren't supported yet either)
One option is to implement a renderer for ui:DateTimeField that can handle cases with and without timezone, either with a custom datetime picker or with a second selector to choose the time zone.
Another option is to define multiple ui variants, e.g. ui:DateTimeFieldWithTimeZone and ui:DateTimeFieldLocal, with the latter specifically mapped to a datetime-local input field.

@timea-solid timea-solid removed the forms label Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants